Basic implementation of union, intersect and diff (TODO: add tests)