Fix bug in linking, and also make sorting case-insenstive