valgrind fixes
parsing fix
handle EPIPE
state machine fixes
mm fixes