Fix compile error in GCC due to missing include and fixed some signed/unsigned comparison warnings