Removed the casts and placed one into the trait, plus stylistic changes