Added/fixed error handling, added channel detection.