Features/threading

Merge in threading support