Profiles sort properly now.

Fixes #259

Also some tidy ups around cursor hygiene and timestamp formatting.