More flexibility improvements courtesy of Luke O'Sullivan.