Bug fixes in parsing and generation