Typos and due casts. As for the latter. It's "safe" to cast as below,