copied changes from flaming-nemesis