fixed all -R errors in valgrind