Create Context struct, move to less imperative style using struct implementations