add some comments and cleanups