initial flowlayout code. works well. needs testing.