Fix some cannot cast errors