introducing stately.rs and lots of resulting refactoring