various optimizations and build/scons related changes