Minor comment additions and a small amount of code refactoring