Pending Restart...even after Restarting

It sounds like your custom package needs more than one reboot sometimes to complete the installation.
Have you taken a look at the flags that remain after you reboot the machine?
This thread may be useful.