Fixed potential bug, added warnings.