More refactoring. Looking pretty neat and tidy now.