SECOND AMENDED AND RESTATED TERM LOAN AGREEMENT