Removed session storage, restructured code