Rearrange if statements. Closes #60.