cleanup magic.c