Refactor InputTokenizer

Fixes #12.
Fixes code duplication and makes code more readable.