Handle null's in element.as_x better

Now with a proper debug message instead of giant stacktraces!
Also, fix some bad meta and inaccurate debugging.