fix unused var and block shadowing warnings