Several Changes, Loggin function added.