Rewrote for redmine 2.3 compat