Performed some minor refactoring to free more RAM