Added some stuff, simplified code and corrected mistake in sampling. Added gamma correction in gui