Refactoring and code cleanup. Changing layout.