cleanup as per @javanthropus review comments

mostly formatting, refactored #readpartial and #read_nonblock