Moved computation into worker, fixed error handling