Updated functions and variables
Also added indexes
Fixed Merge