Bug fixes

small fixes in the code. Pointer dereferencing, and variables that were
defined incorrectly.