Added fixes
Changed code structure