Scoping of variables, removed old class and dead code