Adjusted BaseActiveRecord code for better noSQL compatibility