update dependencies and refactor some code