Detect undefined properties and identifiers, and invalid function calls.

Fixes angelozerr/tern.lint#1.
Fixes angelozerr/tern.lint#2.
Some cleanup and comments.