Add title field and clean up code