Fixed some signed/unsigned comparison issues