Did a bit of refactoring/simplification of variable related logic.

Signed-off-by: Jakob Brandsborg Ehmsen <jakobehmsen.github@gmail.com>