Perrys right about 4.0 being bad news. And not just in regard to PRI. But you also have a bad NVM release. Upgrade the mail to 4.0.04E or 4.1 and the MICS to at least 4.1 and upgrade the NVRAM cartridge to Rlse2. If you are using the one that came with your software it will be a Rlse 1, and they were defective. Personally, I have had no problems with 4.1 on several large systems, including one with 2 spans of PRI. By changing the RAM cartridge and upgrading the mail and MICS s/w, likely all your problems will go away. But if you want to go all the way, go to 6.1
And don't forget to reprogram the mail to renumber trunks