fix bug in module deletion code