Fix for crash when passing undefined

Fix for crash in 2 places when inadvertently passing undefined.
Merge pull request #10 from keyle/master

Fix for crash when passing undefined