Fixed merging features bug

This fixes a really serious bug with merging multiple feature sets. Any results generated from experiments where multiple feature sets were merged were completely wrong before this fix.

Mike and Nitin did most of the work, but I put together the unit test.