Removed unused var
Removed unused vars
Some code cleanup
Additional declarations to resolve type warnings