fixed the main issues reported by Peter Breitenlohner cleanup speedup * catalog.c: fixed the main issues reported by Peter Breitenlohner * parser.c: cleanup * valid.c: speedup patch from Petr Pajas Daniel