fixes for bugs found by Gajen