Fixed some casting error.