Some fixes for SMILES/SMARTS valence handling