Clear code. Follow conventions.

-Cleaned syntax to make more readable code.
-Followed conventions for including header file.
-Converted few c api calls to cpp api calls.
-Removed unused variables.