data rewriting and fixes