Adding sorting to lists and a few minor changes