Major cleanup. (Remove tons of duplicated and even unused code)