I have just had a quick scan of the code, I don't think there is anything broken as such, just very cumbersome code for what needs to be done and sometimes a roundabout way of doing it.
Firstly you don't want to be performing the following on shared hosting for every user that connects.
$sql = "SELECT COUNT(*) AS num_addresses, MAX(balance) AS max_balance, SUM(balance) as sum_balance, ";
$sql .= "MAX(totalbalance) as max_totalbalance, SUM(totalbalance) as sum_totalbalance ";
$sql .= "FROM balances WHERE email <> 'SERVERBALANCE'";
The math should be done in PHP to take some of the load on the SQL Server.
Also there is 12 calls to the SQL Server in the index.php file alone. let alone any external functions that are called from core.php.
I think the best fix would be to change software or upgrade your hardware.
I am using this script becausr it has a referral system. I also have a custom theme integrated with this theme.I think it will be a lot of work to migrate to new script.