Holy shit, what have I done

Who knows how old all this crap is, just put it in master and fix it as I go.