minor refactorings to tidy up convert