Fixed redstone simulator crash

* Fixes #1176
* Fixed #1186