Improve es5 strict mode compatibility.

In es5 strict mode "function" could only be a top-level statement.