more cleanup and testing
made DAO generic get more generic.