Fixed potential NPE's for usernames

Added some null checks for getting username of the active user.