Split element creation to a function.
Fix non-working title option (ignored when using replacedWith?).