An agreement has been reached that will allow a German-operated cargo ship to leave the Lake Superior port in Duluth, Minn., where it was detained for more than a month due to alleged environmental violations, the U.S. Coast Guard said Thursday.

A Coast Guard spokesman, Petty Officer 3rd Class Christopher Yaw, said the oceangoing M/V Cornelia was making preparations to depart the port of Duluth. Yaw said he had no details of the agreement.

Adele Yorde, a spokeswoman for the Duluth Seaway Port Authority, said the Cornelia should be ready to depart before noon Friday. The crew was working Thursday to resupply the ship with provisions.

“The wheels are in motion to get the vessel out of there,” she said.

The first visible movement after nearly six weeks of stalemate came Wednesday when the Cornelia was allowed to dock. It had spent more than a month at anchor just outside the Duluth harbor while the Coast Guard investigated the alleged discharge of oily water somewhere other than Duluth. The crew of 19 Czechs, Ukrainians, Filipinos and Croatians had little to do but wait since taking on a load of grain destined for Tunisia in early November.

The Coast Guard had said previously that it wanted to have a security agreement in place before releasing the vessel.

Yorde said volunteers from a seafarers’ ministry visited with crew members Thursday. They helped the crew with Internet access and brought them candy bars and hygiene products. Yorde said the volunteers reported that everybody seemed to be in good spirits and in good health.

Why the dispute took so long to resolve remains unclear. The Coast Guard has provided few details, saying the investigation was ongoing.

The 576-foot, Liberian-flagged Cornelia is managed by the German shipping company MST Mineralien Schiffahrt. Company officials haven’t responded to requests for comment from The Associated Press.

The ship’s owners and managers were under pressure to reach an agreement soon. That’s because oceangoing ships typically try to leave Duluth no later than Dec. 18 because of the time it takes to cross the Great Lakes before the St. Lawrence Seaway closes for the winter.