More refactoring, removing redundant code.