A bunch of fixes all around, we can now merge back to master, but maintian this branch for further development