numerous small fixes