Cyril was so obviously based on Billy Bunter that the BBC had to issue a denial that there was any connection between the characters. This was broadcast during the closing credits of episode 4.
The final script we see on screen is the third that was written and only the characters remain from the initial script, with the plot being overhauled completely.
Another interesting fact that ties these two together is that one of those rewrites is because the story had already been accused of stealing ideas and characters once before from a Gerald Savory play.