Fix bug reported by janoliver in #21