Version 0.2, rewrite to add threads