Catch and handle tun write exceptions

by printing an error message...
also i cleaned up code and printing more
log messages to help with debugging.