cleanup .chain and .chain_err + fixing other files