many fixes and cleanup- most importantly, we now apply patches.