Thank you for your suggestions. While it didn't fix the problem it certainly helps to improve my code (stupid me forgot about taint mode).
If anyone has a idea why I encounter the problem (and how it could be fixed) that would make me a real happy man.