removed recursive elements, added minor speedups