added ordered by to SELECT * FROM LINKS and fixed some minor bugs