Cleanup + DB query performance tweaks