Minor tweaks to logic