Cleanups and performance tweaks