core: introduce internal _append function to DRY out some code.