Bugfix

All kinds of tidying up