Tidying up error handling & logging, and reducing buffer sizes to more sensible level