Implemented global tick hack and also cleaned up some codes