Make simplify() online, linear time & constant memory.