Added support for redstone latching

Fixes #856