[MAJOR] Partial rewrite of a couple of files.