Adapted to the latest Rust and ported to Cargo