commenting, cleanup and refactoring