Semi-working code. Still need to finish that TODO. Then, work on
threading and handle exceptions.