Change var name convention and clean up code