more refactoring and allowing master cells to be optional