Patch ugly duplicated code.