some cleanup, added comments