Made numerous fixes