Several fixes

Original author: Igor Paliychuk
Merge pull request #74 from dorkster/fixes

Several fixes