Clean up repr definitions
Allow injecting input and output functions
Add error location details