Os refactoring 2

This supercedes #22