A little bit of refactoring and cleaning up...