Update libraries, code refactoring