We study the structure and evolution of the hyperaccreting disks and outflows in the gamma ray bursts central engines. The torus around a stellar mass black hole is composed of free nucleons, Helium, electron-positron pairs, and is cooled by neutrino emission. Accretion of matter powers the relativistic jets, responsible for the gamma ray prompt emission. The significant number density of neutrons in the disk and outflowing material will cause subsequent formation of heavier nuclei. We study the process of nucleosynthesis and its possible observational consequences. We also apply our scenario to the recent observation of the gravitational wave signal, detected on September 14th, 2015 by the two Advanced LIGO detectors, and related to an inspiral and merger of a binary black hole system. A gamma ray burst that could possibly be related with the GW150914 event was observed by the Fermi satellite. It had a duration of about 1 second and appeared about 0.4 seconds after the gravitational-wave signal. We propose that a collapsing massive star and a black hole in a close binary could lead to the event. The gamma ray burst was powered by a weak neutrino flux produced in the star remnants matter. Low spin and kick velocity of the merged black hole are reproduced in our simulations. Coincident gravitational-wave emission originates from the merger of the collapsed core and the companion black hole.