Fix the casting to int bug.