Fixed findOne memory issues

Found by running all the tests through valgrind.
Fixed a few memory issues - mostly double frees.