Added a regerssion test.  Made an algorithmic optimization.