Kill memory leak, and fix a bug by adding a default model