Update dependencies and refactor