Bug fixes

This fixes #1