Combine download function with other functions, replace library