fixes from code review by Mikko