Switch if conditions to elseif. See #121.

The original version of this function had each condition block return early if the condition evaluated to true. That was converted to a single point of return in ce44821 at the end of the function, so that the return value could be filtered.

That conversion changed the execution logic so that all of the conditions are ran in all cases, rather than a true condition short-circuiting the conditions that follow it. This commit restores the original logic.