Improve input parsing

Attempt to differentiate between single quotes that start quotations
and those that are used as apostophes.