Worried about nothing...
Dude you are completely worrying about nothing. 40,000 in cash is chump and if you've been in China long enough, you'll know that people buy million dollar houses in Cash. The customs/security guy won't bat an eye lid if you look the type. If you look a little unsavory they may want to question you. Bear in mind you cannot tell them that you earned this money teaching in China as a) you probably dont have a valid work permit and b) you probably have not paid taxes on this income.
My suggest = split your stash. Keep around 20k in your money belt and the balance in your backpack/briefcase. At shanghai airport if departing internationally, you can buy foreign currency after security so that may be another option for you. Unsure of whether their rates are competitive or not.
Good Luck.