fix previous commit for Rails 3.0 and misc code cleanup