Fix the serialize benchmark and remove variables from global scope