Fixed bugs, using BigMatrix for better memory usage