Heavy overhaul for cleaning up libraries