Implemented more fixes as suggested.

Implemented Fifo cache, to prevent increasing to unlimited size.

Tests are not yet ready.