Fix for Bug #3251, plus fixed a couple of regular expressions. Also added tests.
All Blast tests pass.