diff --git a/pycardium/main.c b/pycardium/main.c
index 68bbc2c10c1df23aec6fa1ee3bc5bf1a1aaa1dd8..55d2e060abef1d9ac3c6ae5dc703b0acec245796 100644
--- a/pycardium/main.c
+++ b/pycardium/main.c
@@ -16,13 +16,12 @@ int main(void)
 	/* TMR5 is used to notify on keyboard interrupt */
 	NVIC_EnableIRQ(TMR5_IRQn);
 
-	gc_init(heap, heap + sizeof(heap));
-
-	mp_init();
-	pyexec_friendly_repl();
-
 	while (1) {
-		;
+		gc_init(heap, heap + sizeof(heap));
+
+		mp_init();
+		pyexec_friendly_repl();
+		mp_deinit();
 	}
 }