Also makes more sense conceptually, since it's not like we'll ever have negative frames.
and some things suggested by cppcheck and compiler warnings.