FIXED #9. Added support for custom merge function.