Many small fixes and changes