[Issue #82] Move variables up to avoid "free variable reference" warning when compiling.