Fixes #20: Invalid cast