Refactoring, progress on decreasing memory usage