Come cleanup for the code and added some comments