Added single-threaded basis. Will work on multithreading it later this week.