Resolves #209 with some extra casting logic.

Performed the casting talked about in the comments for issue #209.