A lot of minor fixes