Added Starwaster's AFG code