Touched some lines in order to make it more similar to working version.