Add undefined checks and warnings. Issue #45