Fix two bugs introduced by poly-castings, reported by @vevix

Closes #134