Fix event channel offset calculations. Various code improvements and additional error handling.