Port of ActiveRecord from KhausFramework