clean up lib code