Yes, I ran a consistency check and there was a list of things to be fixed. I took a backup then fixed the things. I reran the consistency check and there were no more inconsistencies. Unfortunately, my problem of trying to create classes and getting the "illegal" message remained.
Because it appeared that some packages remained locked and some were not I thought maybe the switching between locking policies had caused the problem. So I have switched it back on, then switched it back off. It took something like 20 minutes but I made sure that it completed. Good news, everything is unlocked and I can now create classes again (phew!). I suspect that I lost network connection when I switched between locking policies previously, which put the repository into an inconsistent state (but not one that the inconsistency checker could pick up). I won't be doing that again anytime soon!
Thanks for all your assistance, much appreciated.