Lots of beam fitting code.