Cleaned up the code somewhat, and sped up the compilation time by quite a bit.