Added isEndOfInput and reorganized module