Clean up title generating code