Define optional size, add tests, refactor flash