Made thread-safe refcounting in SGIO, Version and Parallel

Moved RefCount to own file and used that class for ref counting instead of a plain int in the classes SGIO,Version and Parallel