Bug fixes as reported by Emanuel