Fixed erros in some situations.