Fix runtime and build issues. Also removes a warning.

Fix incorrect undefined check, as seen in 703cc93