some code cleanup and commenting
minor fixes