some utilities and cleanup