added leg static function; organized http and sesssion code into components