move entity functionality (templates) from service to library