Fixing some errors, including annoying unsigned long warnings