jshint fixes and refactor of clean_input method