Rewrote the data access layer for more efficient queries