Made variables private

Made use of closures to make internal variables private.