Repairs on the export functionality, now respects environment, and handles bad json in events options