Make typecasting an extensible hook instead of a hardcoded routine



<!---
@huboard:{"order":134.0}
-->