Refactored beam() routine.