schema free CHANGE compiled and main module must be freed separately

This allows for some additional asserts
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 1500534..89db6db 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -1352,6 +1352,8 @@
         /* make the module correctly non-implemented again */
         m->implemented = 0;
         lys_precompile_augments_deviations_revert(ctx, m);
+        lysc_module_free(m->compiled);
+        m->compiled = NULL;
     }
 
     for (i = 0; i < unres->creating.count; ++i) {
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index da2f1e2..6d31a75 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -12,6 +12,7 @@
  *     https://opensource.org/licenses/BSD-3-Clause
  */
 
+#include <assert.h>
 #include <stdlib.h>
 
 #include "common.h"
@@ -1013,8 +1014,9 @@
     if (!module) {
         return;
     }
+    assert(!module->implemented);
+    assert(!module->compiled);
 
-    lysc_module_free(module->compiled);
     FREE_ARRAY(module->ctx, module->identities, lysc_ident_free);
     lysp_module_free(module->parsed);