Added beforeSend and error callbacks