lots of minor fixes