Made slight changes from Hexane's fork