Add some assertions to check for null values.

Counter registers are checked before being used
Fix a bug in the serial algorithm.
Fix a bug in serial.c

There was a problem with an index
Add debug.h for debug prints
Add some datasets