Rewrote files to be more modular and logical.