Some tidying, not tested yet.