fix memory leak, also add option to pass X as parameter.  allocate lu arrays in place