Bug fixes + improvements.
Merge pull request #87 from mshamash/master

Bug fixes + improvements.