Corrected some errors in implementation.

Some incorrectly named variables and missing

an include header file.