more work on internal representation, and some tidying