lots of small fixes and extensions