fixes #31 and some other small issues