This is My mod, somewhat following Pahimar's Let's Mod code.