refactor: improve code quality with clippy fixes and optimizations