Last year was one of the worst on record for global shipping.

Maersk Line, the container industry giant, posted one of its biggest losses in 70 years. Hanjin of South Korea became the first big containership operator to enter bankruptcy since 1986. Almost all of the top 15 lines merged or joined new alliances. Freight rates hit historic lows. And containerships, some just seven years old, were sold at rock bottom prices for scrap.

The simple economic theory of supply and demand is behind the chaos — there were too many ships chasing too few cargoes. Analysts say the industry is largely responsible for its own predicament because too many stakeholders misread the market.

“Before 2008 and 2009, the world had been growing consistently and after 10 years of growth, no one in the shipping industry expected demand to shrink so fast,” Rahul Kapoor, director of shipping consultancy Drewry Financial Research Services in London recently told the BBC. “To start with, they thought it was just a blip. But in reality, it was structural, and they totally missed the structural problems.”

Container lines remained overly optimistic about demand even as the world economy remained sluggish. Seduced by the promise of an expanded Panama Canal and the notion that the best way to cut costs was to increase scale by building bigger and more fuel-efficient ships, they invested cheap money in bigger vessels.

The result? Shipping companies expanded faster than global trade, with the average size of a container ship ballooning by 90% in the past two decades and significantly increasing total fleet capacity. In the meantime, smaller Panamax ships were sold off or scrapped.

This might ring familiar to many in the domestic barge industry, also languishing with too many barges and not enough demand. While the container lines were building huge, neo-Panamax ships, inland river operators were building new barges to meet the demand from fracking fields, crude oil, grains and coal. The bottom fell out of these business lines last year (with grains being a notable exception), producing a glut of idled barges along the inland river system and a huge dip in barge freight rates.

Both brownwater and bluewater are now looking to right the ship — and there have been positive signs of recovery. Both sectors have undergone a consolidation wave over the past year, and companies have stopped ordering new vessels and barges or have deferred deliveries. Maersk, for example, was the first to push back delivery of nine ships from 2017 to the end of 2018.

Although this hurts shipyards, stopping or delaying newbuilds should help reach equilibrium — supply/demand balance. Consolidation and ship scrapping mean there will be fewer barges and containerships in the fleet, and this should help boost freight rates. Many analysts predict that recovery will take time, with improvements not seen until the end of 2017 or beyond, as barge companies and containership operators absorb the excess shipping capacity, and consolidations continue.

Drewry, the shipping consultancy, forecasts a 12% increase in global freight rates this year after a four-year decline, while Maersk predicts a 2% to 4% hike in demand for oceangoing container services.

But factors that have little to do with the economics of shipping could affect the recovery. Slowing global trade could worsen should the protectionist Trump administration succeed in pulling back on U.S. trade agreements and sparking a trade war with China.

In addition, attitudes toward consumer goods are shifting, with decreasing demand for the goods that fill containerships, and more demand for the virtual, digital stuff that fills our smartphones and tablets.

Pamela Glass is the Washington, D.C., correspondent for WorkBoat. She reports on the decisions and deliberations of congressional committees and federal agencies that affect the maritime industry, including the Coast Guard, U.S. Maritime Administration and U.S. Army Corps of Engineers. Prior to coming to WorkBoat, she covered coastal, oceans and maritime industry news for 15 years for newspapers in coastal areas of Massachusetts and Michigan for Ottaway News Service, a division of the Dow Jones Company. She began her newspaper career at the New Bedford (Mass.) Standard-Times. A native of Massachusetts, she is a 1978 graduate of Wesleyan University (Conn.). She currently resides in Potomac, Md.