Big refactor

Makin things less shitty.