Migrate to new entity api

Fixed code.
Commented out tools to make compile; Must be migrated later