Code restructure