Added some controls code and trim on save.