fix undefined
enforce validness, fix ui loading and saving bugs