With the growing availability of devices capable of capturing information about their surroundings and the expansion of mobile connectivity, Internet of Things (IoT) solutions are increasingly been integrated into society. For IoT solutions to emerge successfully on the market, they will employ more than traditional mobile computing, but they will also require the use of everyday objects in an interconnected way. This interconnected world will support the intelligence in environments. In order to provide this infrastructure for environments, it will be necessary to propose platforms for software development based on context awareness and context processing. In this sense, this article proposes CMFrame, a framework for managing contextual information captured from physical environments using hierarchical and dynamic entities. CMFrame allows that entities to modify their hierarchical organization to manage environments and their related contexts. Contexts linked to each entity are also dynamic and can store different amounts of values at any time. The article presents the proposed framework and its evaluation through two applications focused on intelligent enviroments. The fisrt is dedicated to monitor the movements of entities in an environment, and the second addresses energy monitoring. The scientific contribution of CMFrame is the proposal to abstract the management of dynamic and hierarchical context histories through a framework.