fix pedestal error and start refactoring