Fix some class casting bugs