Reorganized the dao code to use entity meta.