these changes fixes some of the world's most stupid code
lots of code cleanup and attempts some rules that suck