Fixed FIFO and some minor bugs