Some optimizations here and there

Nothing extraordinary. Reduction of codes, a bit of renaming. Not
mandatory to merge. But it helped me to get through the code. :)
fixing typo
Merge pull request #10 from karlcow/optimization

Some optimizations here and there