Handle timeouts
Minor javadocs updates
Handle encoding and fix bug in close()