optimizing, commenting, renaming variables

renaming variables; small optimizations; adding comments, FIXME; removing unecessary lock/unlock (#129).