Code cleanup & refactoring.