Added code based on Hollow's commit.