more refactoring in reef-io (still not finished)