Switch from functions to objects with attributes