cleanup and fixes in entities