a few minor tidyups and bigfixes