Fix some error conditions