Refactorings and improvements.