Reduce redundancy in queens code.