GM used flawed system to yank N.Y. franchise, judge rules