Extracted common methods into library file Tools.cpp along with its head...

...er file Tools.h.