Merge branch 'Martin'
endgame has been implemented, not fully tested