fixes for bugs highlighted by fim code