Cleanup and refactor some methods.