Fixed bugs and implemented cert. auth.