Misc fixes

You seem to have the most up-to-date fork, maybe you would like these bug fixes.