Various corrections and modifications; improvements to error-handling.