Fixed regression. Optimized merge step.

Fixed problem with data allocation in constructor. Reduced number of
comparisons in merge step by using a priority queue.