Minor refactoring and some explanation.