Refactoring dupllicate code and unreferenced methods.