added sorting in favs and other occurences of for-each iteration;
fixed a bug in gallery ajax request;
fixed the favorites bug;