Refactoring of base station code