Hard reset only when gpu-threads or devices are changed, but not when algorithm is changed.
Also a little refactor.