A bit of refactoring and sanity injection

(tell me when you find that...)