Refractor part 1

Refractor the part of the mod that I had on my harddisk