Converted timer code from c style to c++.