Fixes #3 and cast typing