Improved recent pane performance, and fixed the sql