Refactor main and actor to calculate tps on the fly