Add support of libraries; refactoring.