Have you tried breaking down your code into subroutines and testing each one? Also, do you need to use speedycgi? If you divide up what you're trying to do and troubleshoot each part, it makes it easier (less to deal with, i.e. if you use variables local to the subroutines) and you won't be hogging as much CPU in doing so. If you could, please let us know a bit more about what you're trying to do.