Improvements on session and authentication