Partial code structure refactor