Fixing some slight memory leaks