More robust parsing algorithm.