Declared ints as unsigned to remove warnings