Fixed a couple of InvalidOperationException errors