improved implementation of parseCat etc.