Imported entity logic and removed unnecessary debug.