ui bugfixes and better database resources managemet

+ some strange ui behaviour when creating and editing orders is fixed
+ fixed some resources memory leaks