Fix bugs in timer and functional API.