Fixed flashes, code cleaning