Refactor lazy tables and factorize