Fix a couple of subtly incorrect casts pointed out by nostar in IRC, thanks nostar! :-)