correct references, clean up output