Rearranged some code and added some program.