Graph algorithms: Implement breadth-first iterator and cycle-detector.
Fix several bugs in constant-reduction. Also some bugs in code-generation.