Fix many bugs and add quicker cleanup