Merge branch 'stage' into stage2
Fixes for correctness and to get tests to work
Merge branch 'stage' into stage2