Improve error messages
add fallback to reinterpret_cast if dynamic_cast fail