STOCK PURCHASE AGREEMENT among PMA CAPITAL CORPORATION, and Charles C. Caldwell, Thomas G. Hamill, Colin D. O’Connor, and J. Mark Davis (the Shareholders of Midlands Holding Corporation) and MIDLANDS HOLDING CORPORATION Dated as of October 1, 2007