Do some refactoring. Update to recent rust.