fix a bug same as https://github.com/matobaa/Redmine-LDRizePlugin/issues/1, and code cleanup