Fix issues 7, 9, 10 reported by Martin Ettl.