Do not require the user to cast the code behind class.

This patch allows the user to get an instance of the code behind class without needing to cast it manually to the correct class. Unfortunately, at the current state this patch provokes many "raw type" warnings in the framework. Maybe someone is in the mood to fix them. ;-)

User code can be written without these warnings, though.