Split io

This is a fixed, cleaned up and rebased version of the oo-io branch (#520) plus two more commits.