Various fixes
Input refactoring and fixing