refactor to materials, pulled base classes into context lib