Fully implemented sequential version, added some tests and stuff