Add comments and move generator to correct place