Added security layer, login/connect function implemented and some minor changes