Move input validation functionality into a separate module.
Move Python 3 compatibility code into a separate module.