Correct tons of bugs and improve stability