Fixed a bug where instances were being marked outside of a transaction