Code cleanup

Code cleanup (comments, some efficiency improvements)