Adding comments and moving some variables around