Fix for memory leak. And add forgotten break