Updated to current rust, and used more idiomatic code