pica: fix handling resize and dynamically adjusting layout better