Clean up length checks with a macro and comment strange semantics