minor code cleanups - add comments, remove unused var, declare function as static