implementations and cleanup