diff --git a/src/spfx.c b/src/spfx.c
index 5616ed8..49f9bf2 100644
--- a/src/spfx.c
+++ b/src/spfx.c
@@ -215,6 +215,10 @@ int spfx_load(void) {
   /* Shrink back to minimum - shouldn't change ever. */
   spfx_effects = realloc(spfx_effects, sizeof(SPFX_Base) * spfx_neffects);
 
+  /* Clean up. */
+  xmlFreeDoc(doc);
+  free(buf);
+
   /* Now initialize force feedback. */
   spfx_hapticInit();