Code refactoring, update libraries