AMENDED AND RESTATED CONVERTIBLE NOTE AND WARRANT PURCHASE AGREEMENT