Added optimistic record locking and ActiveRecord base class