warning fixes (after checking on jshint.com) and performance improvent

Added semicolons, removed unused variables,  changed way for cloning an
array.