fixed various bugs from last commit
Merge pull request #11 from mung3r/master

sync