rejig and bug fixes