ported linq and tests.