Handle edge cases more cleanly.