Fix issues in export with trim enabled