Complete redo of a lot of code.