fixed a few error-prone areas where opening a new file would cause problems.
Added some randomness to the test pattern generator
Added context selection to score view
fix a small error-prone area where opening a new file would cause problems.