In general I recommend placing truthy if/else branches before untruthy ones, since it makes code easier to read. Seems like there are lots of cases in this file where there's a falsy branch followed by a truthy branch.