Bug fixes. Put in workaround for strange issue where SVD was failing in draw_sample.