lots of small fixes