Restructuring library; some basic cleanup.