added comments, minor optimizations