some commenting and code cleanup