Cleaned up Entity code