Added version number.
Added safe casting for reference and value types.