stable cpu version, passed valgrind checks