Performance tweaks and memory tweaks