Add component support to entities and refactor entity logic