Remove unsafe code and use as for type conversions.
Merge pull request #4 from arjantop/master

Remove unsafe code and use as for type conversions.