Issue 759

This will fix #759 and add detection for out-of-order shares. It will try to fix them as good as possible but there will still be (very rare) cases that this will fail.