Put in basic structure and reorganized codes