Cleanup code/add more comments