Rewrote some of the code to fix some lag issues.