Improved log in handling.