Fix undefined element errors.

fixes issue #5