Minor rewrite

A few rewrites and some paranoid (if not useless) sanity checks.