Major cleanup, adapted to new libraries