halfway merge of entity refactor
finished halfway merge