resolved reference list ordering issue, cleaned and refactored database.sql