Reorganized core code