Hi LordMMX,
I won't help you, I have no time left plus I don't know Pascal/Delphi, but I find it usefull in C development to activate all warnings at compilation and study them carefully.
Another usefull thing is to use a static analysis source code checker, it exists probably: Have a look at
http://www.scitools.com.
A poor man solution is to check *every* argument at the beginning of *every* function call for a range of authorized values, even if this seems quite stupid and time consuming.
Good luck.