Added beginning of threading functionality