Fix a bug in cascades with unclosed invocations. Also make the compiled code a bit clearer, albeit more verbose.