Fix bug in wall. Modularizing reduce.