switch to criteria api; minor improvements