added optional type to threadarray, will merge to rest