added automatic filesystem cleanup function