Slightly DRYed up appendChild and attachChild