Some EDoc comments and a small cleanup in the main loop