Some bug fixes
Merge pull request #9 from xbobo/bugs

Some bug fixes