Resolves #209 with some extra casting logic.