Multiple small fixes suggested by Tobias