Corrected login and small refactorings

Signed-off-by: Paul Săpunaru <paul.sapunaru@gmail.com>