Finished performance refactoring