Fixes #363 Invalid cast exception
Merge pull request #364 from petedavis/Issue_363

Fixes #363 Invalid cast exception