finished(?) iter-ifying functional implementations. Only flatten remains