#123: Remove some obsolete TODOs re. type checks.
#123, #100: Implement stack_element_ref().
#123, #100: Use stack_element_ref() where appropriate.