Simplification and repair

Much smaller, nicer, and more reliable