Cleaned up code, added consts everywhere I could