Fixed bug with casting.