Minor refactoring. Dao optimization.