Fix problem of cast dictionary mutating

Removes the cast_funcs dictionary as a class instance and ensure that
it's set up for each instance. Also renames the variable so it's a bit
clearer what it does.