Fixed some stability bugs and added Gamma correction