second batch of fixes from code review