Fix wrt sortby parameter.
minor security tweaks.