Simplify string duplication function a bit.