Fixing input managing and refactoring some useless code