Merge pull request #412 from stan-dev/bugfix/issue-367-local-var-index-decl

Fixes #367.
Merge pull request #411 from stan-dev/bugfix/issue-379-sd-grad-at-0

fixes #379.
Merge pull request #416 from stan-dev/hotfix/v2.0.2

Merging temp hotfix branch back into develop