CONFORMED COPY AMENDED AND RESTATED STOCK PURCHASE AGREEMENT dated as of October 19, 2004