Big refactoring!

This will be a bit confusing. Stick with me!