Fixes #158 along with other small things.