beam/examples/beamsh: move code around for readibility