Re-added some casts that got lost during merge (plus some typo fixes).