header and session cleanup