Big fkn refactor. Can't even remember what I did. I should really commit more often