Fixing some possible failure bugs