fixes for Rails 3.0, plus misc code cleanup