Fixed some issues and refactored DAO to be a bit cleaner