Rewrite part of snapshot feature to get connections correctly

I've tried to minimize the amount of code I'm touching to complete this. I'd prefer not to rewrite the entire class.
You could save the issue of having temporary files by using the `php -r` syntax like the old code was using. Any reason this isn't still a good way?