fixed some variable confusion to allow code to complile
resolved circular reference in header files