Added some indexes for better searching, fixed some basic functions