Fixes

Various little improvements. I tried to keep the commits small and coherent, so you can easily cherry-pick.
please keep it as is.