fix null pointer, simplefy generated code, disable uplad in readonly, grey out button in dialog.