Refactor code (in progress).