Compatible with Rails4.  Fixed various bugs encountered