Major overhaul, still needs cleaning up.