more codes and some cleanup