Numerous small fixes