Make some globals in main non-public.

This means they are declared static, and their extern definition in
main.h is removed. Also moved CBlockIndexWorkComparator to the .cpp
file.