Major overhaul, rewriting almost everything