Handle empty non-terminals more correctly and robustly.