Merged project now should work correctly, re-factored code according to jshint