Code clean up and handling FIFO errors

Revision:
69:4305ac772a66
Parent:
24:2d2cb6ac71fd