Fix error when loading ui file. Needs more review.