Added support for sorting the log and showing 20 results.
fixed some math errors