Major timer code re-write for improved efficiency and security.