Separate out host<->target communication more clearly

Will make it simpler to create different transports, in particular
to have same interfaces for a simulated target runtime as real
on-device targets.
Attempt to recover after parser hitting invalid state