Cleanup: use break rather than nested if/else constructs.