reordered some stuff, and removed old code