Improve title parsing to reduce some code duplication. Also fix invalid JSON getting through