update requirements and some refactoring