Minor alterations to logic.