quite a lot of fixes