tons of code cleanup, still under 30% of what is really needed