Cleaning up API code, and adding pdf to text conversion