Fixed bug from invalid class casting.