Fixed casting problems