Rewrote almost everything