Implemented debug mode. refs #440
Some fixes in DAO.stg. refs #437