Better exception message and input stream fix