Performance tweaks, cleanup