More robust parsing method.