If you can, post a followup within this thread providing a minimal snippet that shows what you're doing and replicates the errant behavior. It would assist us in divining what the problem is.
I've found that often when trying to boil a problem down to a presentable snippet I discover the solution myself. YMMV. At very least, doing so will provide us with something to look at to pinpint the issue.
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein