Cleanup of code and remove some non-used variables scattered in the code

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>