Clean up obvious leaks and errors