optimization & code cleanup
Merge pull request #1 from anru/master

optimization & code cleanup