minor tidying up. use error expections instead of UserWarning for errors