Make copy function more robust
fix bug consolidating optimal results
Gaby Bug fix patches

First wave of commits