Numerous fixes for division by zero