Numerous fixes