Find leaks

This adds lots of leak tests to the automated tests.  It also fixes a couple leaks.