Scope some variables
JSHint fixes