cleanup code (spd.c)