Code cleanup, fix reading small files and tests.