Fix bugs and Array structure

Fixed the injected script bug and made the code structure array oriented
to make for easier sorting and searching functionality.