James H's memory leak fixes to Inertia. [originally from svn r6255]