Added debug flag(debug=2) and added stronger input validation
Added debug flag(debug=2) and added stronger input validation, fix indenting
Further debug wrapping and stronger input validation and indenting