Refactor and catch a corner case.

The code wasn't working for the case where the QChem object is created from a Q-Chem input file already, this is now fixed.