Minor refactoring and update libraries