A method to convert DOK representation to CSR representation and other small complementary changes