Adds performance improvements found by code profiling