JSHint fixes

These two commits fix two javascript issues reported by the JSHint commit hook:

- Function declarations should not be placed in blocks. Use a function expression or move the statement to the top of the outer function. (W082)
- eval can be harmful. (W061)