minor fixes (defensive code + efactoring) in reef-io file