Added ref counting
Added features required for second life