Moved keys code to base entity