various replaces and general tidying