Passing reference and values to functions, code now slower?