Rewored based on the feedback from https://github.com/Moncader/SWFCrew/pull/44/