Refactored timer and added tg.log(msg, isError) as a logging function.