some optimations and shadow fixes