Big rewrite of some mechanisms.