UPDATE: more router stuff done and fixed
UPDATE: Cleaning up code, making things easier to read