Some further work before attempted switch to pegjs (not working)