minor code cleanup and restructure on the ActiveRecord side