Fix a bug reported by Andrea Alberti (thanks!)