Fix procedure casting not preserving original value

Closes #233