tidied up common.cpp