move struct-related code to separate library