Made the chain parser more robust.
(In particular, now handles output from hal2chain).