Refactor structs and traits