Expanded one-line if statement
Fixed some comments and added debug logging