Restructured lib directory and also adapted scripts and libraries.