Code clean up.

And include only common.h in .c files

Also, declare some external variables static in .c files.