Minor changes to logic.