debug and cleanup