Fixed warnings for ~0 for unsigned int variables. Also a fix for a bug