Added some performance tweaks for db and php