In 1846, Marine Lieutenant Archibald Gillespie was sent by President James Polk with secret messages to U.S. Consul Thomas O. Larkin in Monterey, California, Commodore John D. Sloat commanding the Pacific Squadron and John C. Frémont. Gillespie, after traveling in secret across Mexico and catching a ship to California arrived early June 1846 with the verbal messages from Polk. What was in the messages are unknown but the Bear Flag revolt came as a surprise to Larkin. On 7 July 1846, when Commodore John D. Sloat with three ships occupied Monterey with his marines and "blue-jackets" (enlisted sailors) and raised the American flag over the Customs House. Commodore (Rear Admiral) Robert Field Stockton replaced Sloat a week later as commander of the Pacific Squadron. Stockton appointed Fremont commander of the volunteer militia formed around his 60-man Corps of Topographical Engineers and the Bear Flag Republicans as the California Battalion and dispatched 160 of them on the USS Cyane (1837) to occupy San Diego and Los Angeles with marine and blue-jacket help. Larkin joined the force sailing for southern California which by 13 August had peacefully occupied San Diego, California and Los Angeles. General José Castro and Governor Pío Pico fled south. Commodore Stockton, the senior military officer in California, appointed Larkin as Naval agent, and Larkin returned to Monterey.