Header file and reference fix

Separate with a header file; fixed reference variables