optimizing, commenting, renaming variables

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