Added timerTick function. Refactoring badly needed.