Inital commit. Works only with a single thread.