Fixes #7 issue with casting entities