Input class, major refactoring