Scattered subspaces and related codes