fixes #2588 - works for non-AR classes too now.