Fix saving advanced search

As the commit says, this was broken by 2e4f75a

I also noticed a typo (I think), so that's included as well.

Finally, the error was being lost from the debug log, so I made sure future errors make their way in there.