Please check out this post as a starting point. It includes a sample addon that demonstrates what exactly the issues are.