optimization and performance tweaks