Reorganize some code in algorithm.js
jslint: Remove the global variable timevalue