Lots of refactorings and cleanings.