Replace version 1 code with basics of version 2