Add indexes; improve code based on jshint