First crack at new design
Fixed up a lot of the code.