Major refactoring. Everything broken and put back together again.