Add a bunch of casts. Don't know which ones are actually needed yet