Fixed build system. Sped up memory allocation.