Use global instance instead of passing layer by layer.

Signed-off-by: johnmave126 <johnmave126@gmail.com>