Refactor out js, implement time measurements