Fix for parameter focusing.

Fixes #414
Consolidated code

Still fixes #414
Merge pull request #416 from MrSprite/procedureFocus

Fix for parameter focusing