Fix signedness-related warnings and reorganize headers