Added class for handling output and end conditions.