Rewrote a lot of stuff