Cleanup and added some comments