Added comments, bug fixes (file dialog), code cleanup