Beacon Roofing swings to profit