Moved entities functions into source