Cleaned up a bunch of cruft, started re-factor.