Smarter ordering of brim loops. #687