Fixing some error cases