Some bugfixes.

Fixes #1