Code quality improvements- Remove various redundant type casts & unused variables.