Image copyright Getty Images Image caption UK water companies made pre-tax profits of £20bn between 2007 and 2016, according to a University of Greenwich study

A tide of grey brown sludgy water oozes out of concrete channels and through a set of grilles just a few miles east of Canary Wharf's shining towers.

This is where London sends its sewage. Half of all the dirty water from the capital's loos - 17,000 litres a second - arrives at the Beckton works to be treated.

The grilles catch bulky rubbish - bits of brick and bicycle are not uncommon - but the main harvest is wet wipes and sanitary products, 30 tonnes a day of the stuff.

Once past the grilles the effluent is sent to settle in giant tanks. The sludge is scraped off the bottom and chewed by hungry bacteria, the fat and oils are sliced off the top, and the cleaned water is put back into the Thames. The Beckton works is the river's biggest tributary.

Thames Water, owned by international investors including Omers, a huge Canadian pension fund, and the UK Universities Superannuation Scheme, has invested more than £1bn in expanding and improving its treatment works, including the Beckton plant - Europe's largest.

However, the scale of the investment has not prevented Thames Water from being dragged into the debate about whether the water industry should be returned to state ownership.

Image copyright Thames Water Image caption Thames Water's treatment plant at Beckton in east London

While Thames has been pouring money into Beckton, it has also been spraying cash over its owners. Over the past decade - for most of which it was controlled by the Australian investment bank, Macquarie - it paid out about £2bn in dividends, paid little UK corporation tax and had subsidiaries in a tax haven, the Cayman Islands.

It has been able to both invest and reward its shareholders by taking advantage of ultra-low interest rates to borrow huge sums. That has sent debt up from £3.6bn in 2007 to more than £10bn. In March last year Thames Water was fined £20m for releasing raw sewage into the Thames, and it has been criticised over its record on controlling leaks.

Other privatised water companies have also rewarded their shareholders well. A University of Greenwich study found that the industry made about £18bn in pre-tax profits over the past decade, and paid almost the same amount in dividends.

Cheap debt, according to critics including the former infrastructure banker Martin Blaiklock, has been used to drive returns to the companies' owners, rather than cut customers' bills.

Image copyright PA Image caption Shadow chancellor John McDonnell wants to renationalise water companies

Claims of excessive returns have given wings to Labour's plans to return the industry to state control. John McDonnell, the shadow chancellor, told the BBC a Labour administration would compensate the industry's owners by offering them government bonds - IOUs that pay a fixed interest rate every year until maturity - in exchange for their shares. Clement Attlee's post-war Labour government used the same mechanism to renationalise the railways.

A study by the Social Market Foundation think-tank found that taking the water industry back into public ownership could cost as much as £90bn if the shares were valued as they would be in a conventional business deal. Mr McDonnell said the study had been paid for by water companies, and that the amount paid in compensation would be set by Parliament.

Water was one of the last of Margaret Thatcher's big privatisations. The 10 big regional water authorities - of which Thames Water was the largest - were sold in 1989. Sixteen smaller water providers were already in private hands.

However, Scotland's water industry remained under state control.

The water companies were monopolies, so to prevent profiteering and poor service, regulators were set up to keep them in check. The Drinking Water Inspectorate had to ensure that water supplies were good quality, and the Office of Water Services (Ofwat) was the economic regulator, with the dual task of encouraging investment and keeping prices low.

Image copyright Getty Images Image caption Margaret Thatcher's Tory government was responsible for privatising the UK's water industry

The water sell-off was partly the result of ideology: Thatcher and other Conservative leaders believed the privatisations of industries such as water, aerospace, energy and telecommunications would break the power of unions and reinvigorate the economy, However, it also allowed the government to sidestep some pressing and large bills for upgrading the UK's water infrastructure.

Sir Ian Byatt, the first head of Ofwat, said that plans for investment a decade earlier had been stalled by the 1976 sterling crisis. After decades of economic weakness following the Second World War, Britain approached the International Monetary Fund for emergency loans and was forced to impose big cuts to public spending in return. "All that spending had to be put on hold, so by the time of privatisation there was a big backlog to make up, and new rules on cleaner beaches and water standards were coming from Europe," Sir Ian said.

The regulator assesses investment plans every five years. After allowing for a return on that investment and efficiencies, it sets prices. Critics such as Mr Blaiklock say that Ofwat has missed the transformative power of the cheap debt available after the financial crisis.

Image copyright Getty Images Image caption A sewer at Wick Lane in east London designed by Joseph Bazalgette in the mid-1800s and still in use today

The regulator can only take action over a company's finances if it loses its investment-grade credit rating. Low borrowing costs have let the water companies load up with debt, pay dividends and make investments, all without endangering their credit rating.

The government is weighing changes to the regulatory set-up. Michael Gove, the Environment Secretary, said he had asked Ofwat to consider what he called "public concerns" over offshore corporate structures and allegations of profiteering: "What I am saying is that if Ofwat thinks it needs new powers, I've got their back."

Ofwat, however, has indicated it is not considering any new financial rules for water companies. Rachel Fletcher, its chief executive, told the BBC a cap on dividends - one measure urged by Sir Ian, for example - was not under consideration.

Instead, she said, Ofwat was likely to set tougher targets in the upcoming five-year review, and force companies to make more information publicly available on executive pay, corporate governance and payments to shareholders.