Cleaned up, added progress bar, works now, terribly slow
Added indices to improve speed