Added more commenting
More refactoring