Fix a lot of issues. Added sort and pagination functionality.