Added more comments
Slight refactoring