Implement top-down simplification

Also some other minor fixes and tweaks