Fix bug reported by Jonathan Bailey