Minor code improvments, fix for random int (now it's saved for all sessions)