Purged a huge amount of legacy code
Added some stuff.