Improve library cleaning and handling of data