Adds benchmarking, strengthens tests, fixes a few memory issues