Refactoring code to be better arranged.