Improve memorial text sorting. Clean up SQL