Fixed crash caused by a cast problem.