Fix #9 and some other fixes.