Fixed login and some environment bugs