Pretty sure this has been a long standing issue but I've not looked at your code to see what API you're calling.
Some authors use this addon here:
http://www.wowinterface.com/download...zBugsSuck.html
This fixes a number of 'issues' with Blizzard code.