Refactors to speed up pretty much everything