Remove unbound variable warnings

Remove unbound variable warnings that were resolved at runtime
While adding a refactoring task is good, i'm afraid that we will never go back and cleanup code base, as higher priority tasks and defects flood in. @lukechurch , what's your idea?