fixes setLayout and reference fields