diff --git a/src/Reactor/Coroutine.hpp b/src/Reactor/Coroutine.hpp
index cd8763c..05d9204 100644
--- a/src/Reactor/Coroutine.hpp
+++ b/src/Reactor/Coroutine.hpp
@@ -157,16 +157,16 @@
 {
 	core.reset(new Nucleus());
 
-	std::vector<Type *> types = { CToReactorT<Arguments>::getType()... };
+	std::vector<Type *> types = { CToReactorT<Arguments>::type()... };
 	for(auto type : types)
 	{
-		if(type != Void::getType())
+		if(type != Void::type())
 		{
 			arguments.push_back(type);
 		}
 	}
 
-	Nucleus::createCoroutine(CToReactorT<Return>::getType(), arguments);
+	Nucleus::createCoroutine(CToReactorT<Return>::type(), arguments);
 }
 
 template<typename Return, typename... Arguments>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 4d232bf..e76e653 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -537,12 +537,12 @@
 	// Use 128-bit vectors to implement logically shorter ones.
 	switch(asInternalType(t))
 	{
-		case Type_v2i32: return T(Int4::getType());
-		case Type_v4i16: return T(Short8::getType());
-		case Type_v2i16: return T(Short8::getType());
-		case Type_v8i8: return T(Byte16::getType());
-		case Type_v4i8: return T(Byte16::getType());
-		case Type_v2f32: return T(Float4::getType());
+		case Type_v2i32: return T(Int4::type());
+		case Type_v4i16: return T(Short8::type());
+		case Type_v2i16: return T(Short8::type());
+		case Type_v8i8: return T(Byte16::type());
+		case Type_v4i8: return T(Byte16::type());
+		case Type_v2f32: return T(Float4::type());
 		case Type_LLVM: return reinterpret_cast<llvm::Type *>(t);
 		default:
 			UNREACHABLE("asInternalType(t): %d", int(asInternalType(t)));
@@ -808,7 +808,7 @@
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 
-	ASSERT_MSG(jit->function->getReturnType() == T(Void::getType()), "Return type mismatch");
+	ASSERT_MSG(jit->function->getReturnType() == T(Void::type()), "Return type mismatch");
 
 	// Code generated after this point is unreachable, so any variables
 	// being read can safely return an undefined value. We have to avoid
@@ -989,17 +989,17 @@
 		case Type_v2f32:
 			return createBitCast(
 			    createInsertElement(
-			        V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2))),
-			        createLoad(createBitCast(ptr, Pointer<Long>::getType()), Long::getType(), isVolatile, alignment, atomic, memoryOrder),
+			        V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::type()), 2))),
+			        createLoad(createBitCast(ptr, Pointer<Long>::type()), Long::type(), isVolatile, alignment, atomic, memoryOrder),
 			        0),
 			    type);
 		case Type_v2i16:
 		case Type_v4i8:
 			if(alignment != 0)  // Not a local variable (all vectors are 128-bit).
 			{
-				Value *u = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
-				Value *i = createLoad(createBitCast(ptr, Pointer<Int>::getType()), Int::getType(), isVolatile, alignment, atomic, memoryOrder);
-				i = createZExt(i, Long::getType());
+				Value *u = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::type()), 2)));
+				Value *i = createLoad(createBitCast(ptr, Pointer<Int>::type()), Int::type(), isVolatile, alignment, atomic, memoryOrder);
+				i = createZExt(i, Long::type());
 				Value *v = createInsertElement(u, i, 0);
 				return createBitCast(v, type);
 			}
@@ -1073,18 +1073,18 @@
 		case Type_v2f32:
 			createStore(
 			    createExtractElement(
-			        createBitCast(value, T(llvm::VectorType::get(T(Long::getType()), 2))), Long::getType(), 0),
-			    createBitCast(ptr, Pointer<Long>::getType()),
-			    Long::getType(), isVolatile, alignment, atomic, memoryOrder);
+			        createBitCast(value, T(llvm::VectorType::get(T(Long::type()), 2))), Long::type(), 0),
+			    createBitCast(ptr, Pointer<Long>::type()),
+			    Long::type(), isVolatile, alignment, atomic, memoryOrder);
 			return value;
 		case Type_v2i16:
 		case Type_v4i8:
 			if(alignment != 0)  // Not a local variable (all vectors are 128-bit).
 			{
 				createStore(
-				    createExtractElement(createBitCast(value, Int4::getType()), Int::getType(), 0),
-				    createBitCast(ptr, Pointer<Int>::getType()),
-				    Int::getType(), isVolatile, alignment, atomic, memoryOrder);
+				    createExtractElement(createBitCast(value, Int4::type()), Int::type(), 0),
+				    createBitCast(ptr, Pointer<Int>::type()),
+				    Int::type(), isVolatile, alignment, atomic, memoryOrder);
 				return value;
 			}
 			// Fallthrough to non-emulated case.
@@ -1231,12 +1231,12 @@
 
 RValue<Float4> Gather(RValue<Pointer<Float>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */)
 {
-	return As<Float4>(V(createGather(V(base.value), T(Float::getType()), V(offsets.value), V(mask.value), alignment, zeroMaskedLanes)));
+	return As<Float4>(V(createGather(V(base.value), T(Float::type()), V(offsets.value), V(mask.value), alignment, zeroMaskedLanes)));
 }
 
 RValue<Int4> Gather(RValue<Pointer<Int>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */)
 {
-	return As<Int4>(V(createGather(V(base.value), T(Float::getType()), V(offsets.value), V(mask.value), alignment, zeroMaskedLanes)));
+	return As<Int4>(V(createGather(V(base.value), T(Float::type()), V(offsets.value), V(mask.value), alignment, zeroMaskedLanes)));
 }
 
 void Scatter(RValue<Pointer<Float>> base, RValue<Float4> val, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment)
@@ -1274,7 +1274,7 @@
 		// x86 supports automatic zero-extending of 32-bit registers to
 		// 64-bit. Thus when indexing into an array using a uint32 is
 		// actually faster than an int32.
-		index = unsignedIndex ? createZExt(index, Long::getType()) : createSExt(index, Long::getType());
+		index = unsignedIndex ? createZExt(index, Long::type()) : createSExt(index, Long::type());
 	}
 
 	// For non-emulated types we can rely on LLVM's GEP to calculate the
@@ -1291,7 +1291,7 @@
 	// Cast to a byte pointer, apply the byte offset, and cast back to the
 	// original pointer type.
 	return createBitCast(
-	    V(jit->builder->CreateGEP(V(createBitCast(ptr, T(llvm::PointerType::get(T(Byte::getType()), 0)))), V(index))),
+	    V(jit->builder->CreateGEP(V(createBitCast(ptr, T(llvm::PointerType::get(T(Byte::type()), 0)))), V(index))),
 	    T(llvm::PointerType::get(T(type), 0)));
 }
 
@@ -1736,7 +1736,7 @@
 Value *Nucleus::createConstantFloat(float x)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return V(llvm::ConstantFP::get(T(Float::getType()), x));
+	return V(llvm::ConstantFP::get(T(Float::type()), x));
 }
 
 Value *Nucleus::createNullPointer(Type *Ty)
@@ -1786,42 +1786,42 @@
 	return V(ptr);
 }
 
-Type *Void::getType()
+Type *Void::type()
 {
 	return T(llvm::Type::getVoidTy(jit->context));
 }
 
-Type *Bool::getType()
+Type *Bool::type()
 {
 	return T(llvm::Type::getInt1Ty(jit->context));
 }
 
-Type *Byte::getType()
+Type *Byte::type()
 {
 	return T(llvm::Type::getInt8Ty(jit->context));
 }
 
-Type *SByte::getType()
+Type *SByte::type()
 {
 	return T(llvm::Type::getInt8Ty(jit->context));
 }
 
-Type *Short::getType()
+Type *Short::type()
 {
 	return T(llvm::Type::getInt16Ty(jit->context));
 }
 
-Type *UShort::getType()
+Type *UShort::type()
 {
 	return T(llvm::Type::getInt16Ty(jit->context));
 }
 
-Type *Byte4::getType()
+Type *Byte4::type()
 {
 	return T(Type_v4i8);
 }
 
-Type *SByte4::getType()
+Type *SByte4::type()
 {
 	return T(Type_v4i8);
 }
@@ -1852,7 +1852,7 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pmovmskb(x);
 #else
-	return As<Int>(V(lowerSignMask(V(x.value), T(Int::getType()))));
+	return As<Int>(V(lowerSignMask(V(x.value), T(Int::type()))));
 #endif
 }
 
@@ -1861,7 +1861,7 @@
 //#if defined(__i386__) || defined(__x86_64__)
 //		return x86::pcmpgtb(x, y);   // FIXME: Signedness
 //#else
-//		return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Byte8::getType()))));
+//		return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Byte8::type()))));
 //#endif
 //	}
 
@@ -1871,11 +1871,11 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pcmpeqb(x, y);
 #else
-	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Byte8::getType()))));
+	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Byte8::type()))));
 #endif
 }
 
-Type *Byte8::getType()
+Type *Byte8::type()
 {
 	return T(Type_v8i8);
 }
@@ -1906,7 +1906,7 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pmovmskb(As<Byte8>(x));
 #else
-	return As<Int>(V(lowerSignMask(V(x.value), T(Int::getType()))));
+	return As<Int>(V(lowerSignMask(V(x.value), T(Int::type()))));
 #endif
 }
 
@@ -1916,7 +1916,7 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pcmpgtb(x, y);
 #else
-	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Byte8::getType()))));
+	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Byte8::type()))));
 #endif
 }
 
@@ -1926,31 +1926,31 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pcmpeqb(As<Byte8>(x), As<Byte8>(y));
 #else
-	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Byte8::getType()))));
+	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Byte8::type()))));
 #endif
 }
 
-Type *SByte8::getType()
+Type *SByte8::type()
 {
 	return T(Type_v8i8);
 }
 
-Type *Byte16::getType()
+Type *Byte16::type()
 {
-	return T(llvm::VectorType::get(T(Byte::getType()), 16));
+	return T(llvm::VectorType::get(T(Byte::type()), 16));
 }
 
-Type *SByte16::getType()
+Type *SByte16::type()
 {
-	return T(llvm::VectorType::get(T(SByte::getType()), 16));
+	return T(llvm::VectorType::get(T(SByte::type()), 16));
 }
 
-Type *Short2::getType()
+Type *Short2::type()
 {
 	return T(Type_v2i16);
 }
 
-Type *UShort2::getType()
+Type *UShort2::type()
 {
 	return T(Type_v2i16);
 }
@@ -1959,7 +1959,7 @@
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	int select[8] = { 0, 2, 4, 6, 0, 2, 4, 6 };
-	Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType());
+	Value *short8 = Nucleus::createBitCast(cast.value, Short8::type());
 
 	Value *packed = Nucleus::createShuffleVector(short8, short8, select);
 	Value *short4 = As<Short4>(Int2(As<Int4>(packed))).value;
@@ -2095,7 +2095,7 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pcmpgtw(x, y);
 #else
-	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Short4::getType()))));
+	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Short4::type()))));
 #endif
 }
 
@@ -2105,11 +2105,11 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::pcmpeqw(x, y);
 #else
-	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Short4::getType()))));
+	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Short4::type()))));
 #endif
 }
 
-Type *Short4::getType()
+Type *Short4::type()
 {
 	return T(Type_v4i16);
 }
@@ -2213,7 +2213,7 @@
 #endif
 }
 
-Type *UShort4::getType()
+Type *UShort4::type()
 {
 	return T(Type_v4i16);
 }
@@ -2258,9 +2258,9 @@
 #endif
 }
 
-Type *Short8::getType()
+Type *Short8::type()
 {
-	return T(llvm::VectorType::get(T(Short::getType()), 8));
+	return T(llvm::VectorType::get(T(Short::type()), 8));
 }
 
 RValue<UShort8> operator<<(RValue<UShort8> lhs, unsigned char rhs)
@@ -2293,9 +2293,9 @@
 #endif
 }
 
-Type *UShort8::getType()
+Type *UShort8::type()
 {
-	return T(llvm::VectorType::get(T(UShort::getType()), 8));
+	return T(llvm::VectorType::get(T(UShort::type()), 8));
 }
 
 RValue<Int> operator++(Int &val, int)  // Post-increment
@@ -2344,16 +2344,16 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::cvtss2si(cast);
 #else
-	return RValue<Int>(V(lowerRoundInt(V(cast.value), T(Int::getType()))));
+	return RValue<Int>(V(lowerRoundInt(V(cast.value), T(Int::type()))));
 #endif
 }
 
-Type *Int::getType()
+Type *Int::type()
 {
 	return T(llvm::Type::getInt32Ty(jit->context));
 }
 
-Type *Long::getType()
+Type *Long::type()
 {
 	return T(llvm::Type::getInt64Ty(jit->context));
 }
@@ -2361,7 +2361,7 @@
 UInt::UInt(RValue<Float> cast)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *integer = Nucleus::createFPToUI(cast.value, UInt::getType());
+	Value *integer = Nucleus::createFPToUI(cast.value, UInt::type());
 	storeValue(integer);
 }
 
@@ -2414,15 +2414,15 @@
 //#endif
 //	}
 
-Type *UInt::getType()
+Type *UInt::type()
 {
 	return T(llvm::Type::getInt32Ty(jit->context));
 }
 
 //	Int2::Int2(RValue<Int> cast)
 //	{
-//		Value *extend = Nucleus::createZExt(cast.value, Long::getType());
-//		Value *vector = Nucleus::createBitCast(extend, Int2::getType());
+//		Value *extend = Nucleus::createZExt(cast.value, Long::type());
+//		Value *vector = Nucleus::createBitCast(extend, Int2::type());
 //
 //		int shuffle[2] = {0, 0};
 //		Value *replicate = Nucleus::createShuffleVector(vector, vector, shuffle);
@@ -2454,7 +2454,7 @@
 #endif
 }
 
-Type *Int2::getType()
+Type *Int2::type()
 {
 	return T(Type_v2i32);
 }
@@ -2483,7 +2483,7 @@
 #endif
 }
 
-Type *UInt2::getType()
+Type *UInt2::type()
 {
 	return T(Type_v2i32);
 }
@@ -2501,12 +2501,12 @@
 #endif
 	{
 		int swizzle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 };
-		Value *a = Nucleus::createBitCast(cast.value, Byte16::getType());
-		Value *b = Nucleus::createShuffleVector(a, Nucleus::createNullValue(Byte16::getType()), swizzle);
+		Value *a = Nucleus::createBitCast(cast.value, Byte16::type());
+		Value *b = Nucleus::createShuffleVector(a, Nucleus::createNullValue(Byte16::type()), swizzle);
 
 		int swizzle2[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
-		Value *c = Nucleus::createBitCast(b, Short8::getType());
-		Value *d = Nucleus::createShuffleVector(c, Nucleus::createNullValue(Short8::getType()), swizzle2);
+		Value *c = Nucleus::createBitCast(b, Short8::type());
+		Value *d = Nucleus::createShuffleVector(c, Nucleus::createNullValue(Short8::type()), swizzle2);
 
 		*this = As<Int4>(d);
 	}
@@ -2525,11 +2525,11 @@
 #endif
 	{
 		int swizzle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
-		Value *a = Nucleus::createBitCast(cast.value, Byte16::getType());
+		Value *a = Nucleus::createBitCast(cast.value, Byte16::type());
 		Value *b = Nucleus::createShuffleVector(a, a, swizzle);
 
 		int swizzle2[8] = { 0, 0, 1, 1, 2, 2, 3, 3 };
-		Value *c = Nucleus::createBitCast(b, Short8::getType());
+		Value *c = Nucleus::createBitCast(b, Short8::type());
 		Value *d = Nucleus::createShuffleVector(c, c, swizzle2);
 
 		*this = As<Int4>(d) >> 24;
@@ -2608,37 +2608,37 @@
 RValue<Int4> CmpEQ(RValue<Int4> x, RValue<Int4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpLT(RValue<Int4> x, RValue<Int4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLT(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpLE(RValue<Int4> x, RValue<Int4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSLE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createICmpSGT(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y)
@@ -2679,7 +2679,7 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::cvtps2dq(cast);
 #else
-	return As<Int4>(V(lowerRoundInt(V(cast.value), T(Int4::getType()))));
+	return As<Int4>(V(lowerRoundInt(V(cast.value), T(Int4::type()))));
 #endif
 }
 
@@ -2723,20 +2723,20 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::movmskps(As<Float4>(x));
 #else
-	return As<Int>(V(lowerSignMask(V(x.value), T(Int::getType()))));
+	return As<Int>(V(lowerSignMask(V(x.value), T(Int::type()))));
 #endif
 }
 
-Type *Int4::getType()
+Type *Int4::type()
 {
-	return T(llvm::VectorType::get(T(Int::getType()), 4));
+	return T(llvm::VectorType::get(T(Int::type()), 4));
 }
 
 UInt4::UInt4(RValue<Float4> cast)
     : XYZW(this)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType());
+	Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::type());
 	storeValue(xyzw);
 }
 
@@ -2776,37 +2776,37 @@
 RValue<UInt4> CmpEQ(RValue<UInt4> x, RValue<UInt4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::getType()));
+	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpEQ(x.value, y.value), Int4::type()));
 }
 
 RValue<UInt4> CmpLT(RValue<UInt4> x, RValue<UInt4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::getType()));
+	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULT(x.value, y.value), Int4::type()));
 }
 
 RValue<UInt4> CmpLE(RValue<UInt4> x, RValue<UInt4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::getType()));
+	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpULE(x.value, y.value), Int4::type()));
 }
 
 RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::getType()));
+	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpNE(x.value, y.value), Int4::type()));
 }
 
 RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::getType()));
+	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGE(x.value, y.value), Int4::type()));
 }
 
 RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::getType()));
+	return RValue<UInt4>(Nucleus::createSExt(Nucleus::createICmpUGT(x.value, y.value), Int4::type()));
 }
 
 RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y)
@@ -2841,12 +2841,12 @@
 	}
 }
 
-Type *UInt4::getType()
+Type *UInt4::type()
 {
-	return T(llvm::VectorType::get(T(UInt::getType()), 4));
+	return T(llvm::VectorType::get(T(UInt::type()), 4));
 }
 
-Type *Half::getType()
+Type *Half::type()
 {
 	return T(llvm::Type::getInt16Ty(jit->context));
 }
@@ -2972,25 +2972,25 @@
 	}
 }
 
-Type *Float::getType()
+Type *Float::type()
 {
 	return T(llvm::Type::getFloatTy(jit->context));
 }
 
-Type *Float2::getType()
+Type *Float2::type()
 {
 	return T(Type_v2f32);
 }
 
 RValue<Float> Exp2(RValue<Float> v)
 {
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float::type()) });
 	return RValue<Float>(V(jit->builder->CreateCall(func, V(v.value))));
 }
 
 RValue<Float> Log2(RValue<Float> v)
 {
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float::type()) });
 	return RValue<Float>(V(jit->builder->CreateCall(func, V(v.value))));
 }
 
@@ -3069,7 +3069,7 @@
 #if defined(__i386__) || defined(__x86_64__)
 	return x86::movmskps(x);
 #else
-	return As<Int>(V(lowerFPSignMask(V(x.value), T(Int::getType()))));
+	return As<Int>(V(lowerFPSignMask(V(x.value), T(Int::type()))));
 #endif
 }
 
@@ -3077,78 +3077,78 @@
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	//	return As<Int4>(x86::cmpeqps(x, y));
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	//	return As<Int4>(x86::cmpltps(x, y));
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	//	return As<Int4>(x86::cmpleps(x, y));
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	//	return As<Int4>(x86::cmpneqps(x, y));
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	//	return As<Int4>(x86::cmpnltps(x, y));
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	//	return As<Int4>(x86::cmpnleps(x, y));
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpUEQ(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUEQ(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUEQ(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpULT(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpULT(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpULT(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpULE(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpULE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpULE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpUNEQ(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUNE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUNE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpUNLT(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUGE(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUGE(x.value, y.value), Int4::type()));
 }
 
 RValue<Int4> CmpUNLE(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUGT(x.value, y.value), Int4::getType()));
+	return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpUGT(x.value, y.value), Int4::type()));
 }
 
 RValue<Float4> Round(RValue<Float4> x)
@@ -3264,12 +3264,12 @@
 
 static RValue<Float4> TransformFloat4PerElement(RValue<Float4> v, const char *name)
 {
-	auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), ::llvm::ArrayRef<llvm::Type *>(T(Float::getType())), false);
+	auto funcTy = ::llvm::FunctionType::get(T(Float::type()), ::llvm::ArrayRef<llvm::Type *>(T(Float::type())), false);
 	auto func = jit->module->getOrInsertFunction(name, funcTy);
-	llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
+	llvm::Value *out = ::llvm::UndefValue::get(T(Float4::type()));
 	for(uint64_t i = 0; i < 4; i++)
 	{
-		auto el = jit->builder->CreateCall(func, V(Nucleus::createExtractElement(v.value, Float::getType(), i)));
+		auto el = jit->builder->CreateCall(func, V(Nucleus::createExtractElement(v.value, Float::type(), i)));
 		out = V(Nucleus::createInsertElement(V(out), V(el), i));
 	}
 	return RValue<Float4>(V(out));
@@ -3333,16 +3333,16 @@
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
 	::llvm::SmallVector<::llvm::Type *, 2> paramTys;
-	paramTys.push_back(T(Float::getType()));
-	paramTys.push_back(T(Float::getType()));
-	auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), paramTys, false);
+	paramTys.push_back(T(Float::type()));
+	paramTys.push_back(T(Float::type()));
+	auto funcTy = ::llvm::FunctionType::get(T(Float::type()), paramTys, false);
 	auto func = jit->module->getOrInsertFunction("atan2f", funcTy);
-	llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
+	llvm::Value *out = ::llvm::UndefValue::get(T(Float4::type()));
 	for(uint64_t i = 0; i < 4; i++)
 	{
 		auto el = jit->builder->CreateCall2(func, ARGS(
-		                                              V(Nucleus::createExtractElement(x.value, Float::getType(), i)),
-		                                              V(Nucleus::createExtractElement(y.value, Float::getType(), i))));
+		                                              V(Nucleus::createExtractElement(x.value, Float::type(), i)),
+		                                              V(Nucleus::createExtractElement(y.value, Float::type(), i))));
 		out = V(Nucleus::createInsertElement(V(out), V(el), i));
 	}
 	return RValue<Float4>(V(out));
@@ -3351,42 +3351,42 @@
 RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::pow, { T(Float4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::pow, { T(Float4::type()) });
 	return RValue<Float4>(V(jit->builder->CreateCall2(func, ARGS(V(x.value), V(y.value)))));
 }
 
 RValue<Float4> Exp(RValue<Float4> v)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp, { T(Float4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp, { T(Float4::type()) });
 	return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
 }
 
 RValue<Float4> Log(RValue<Float4> v)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log, { T(Float4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log, { T(Float4::type()) });
 	return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
 }
 
 RValue<Float4> Exp2(RValue<Float4> v)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float4::type()) });
 	return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
 }
 
 RValue<Float4> Log2(RValue<Float4> v)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float4::type()) });
 	return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
 }
 
 RValue<UInt> Ctlz(RValue<UInt> v, bool isZeroUndef)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt::type()) });
 	return RValue<UInt>(V(jit->builder->CreateCall2(func, ARGS(
 	                                                          V(v.value),
 	                                                          isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
@@ -3395,7 +3395,7 @@
 RValue<UInt4> Ctlz(RValue<UInt4> v, bool isZeroUndef)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt4::type()) });
 	return RValue<UInt4>(V(jit->builder->CreateCall2(func, ARGS(
 	                                                           V(v.value),
 	                                                           isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
@@ -3404,7 +3404,7 @@
 RValue<UInt> Cttz(RValue<UInt> v, bool isZeroUndef)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt::type()) });
 	return RValue<UInt>(V(jit->builder->CreateCall2(func, ARGS(
 	                                                          V(v.value),
 	                                                          isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
@@ -3413,7 +3413,7 @@
 RValue<UInt4> Cttz(RValue<UInt4> v, bool isZeroUndef)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt4::getType()) });
+	auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt4::type()) });
 	return RValue<UInt4>(V(jit->builder->CreateCall2(func, ARGS(
 	                                                           V(v.value),
 	                                                           isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
@@ -3439,9 +3439,9 @@
 	return RValue<UInt>(Nucleus::createAtomicUMax(x.value, y.value, memoryOrder));
 }
 
-Type *Float4::getType()
+Type *Float4::type()
 {
-	return T(llvm::VectorType::get(T(Float::getType()), 4));
+	return T(llvm::VectorType::get(T(Float::type()), 4));
 }
 
 RValue<Long> Ticks()
@@ -3458,7 +3458,7 @@
 	// Note: this should work for 32-bit pointers as well because 'inttoptr'
 	// is defined to truncate (and zero extend) if necessary.
 	auto ptrAsInt = ::llvm::ConstantInt::get(::llvm::Type::getInt64Ty(jit->context), reinterpret_cast<uintptr_t>(ptr));
-	return RValue<Pointer<Byte>>(V(jit->builder->CreateIntToPtr(ptrAsInt, T(Pointer<Byte>::getType()))));
+	return RValue<Pointer<Byte>>(V(jit->builder->CreateIntToPtr(ptrAsInt, T(Pointer<Byte>::type()))));
 }
 
 RValue<Pointer<Byte>> ConstantData(void const *data, size_t size)
@@ -3520,9 +3520,9 @@
 {
 	llvm::Function *rcpss = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse_rcp_ss);
 
-	Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0);
+	Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::type()))), val.value, 0);
 
-	return RValue<Float>(Nucleus::createExtractElement(V(jit->builder->CreateCall(rcpss, ARGS(V(vector)))), Float::getType(), 0));
+	return RValue<Float>(Nucleus::createExtractElement(V(jit->builder->CreateCall(rcpss, ARGS(V(vector)))), Float::type(), 0));
 }
 
 RValue<Float> sqrtss(RValue<Float> val)
@@ -3535,9 +3535,9 @@
 {
 	llvm::Function *rsqrtss = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse_rsqrt_ss);
 
-	Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::getType()))), val.value, 0);
+	Value *vector = Nucleus::createInsertElement(V(llvm::UndefValue::get(T(Float4::type()))), val.value, 0);
 
-	return RValue<Float>(Nucleus::createExtractElement(V(jit->builder->CreateCall(rsqrtss, ARGS(V(vector)))), Float::getType(), 0));
+	return RValue<Float>(Nucleus::createExtractElement(V(jit->builder->CreateCall(rsqrtss, ARGS(V(vector)))), Float::type(), 0));
 }
 
 RValue<Float4> rcpps(RValue<Float4> val)
@@ -3579,10 +3579,10 @@
 {
 	llvm::Function *roundss = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse41_round_ss);
 
-	Value *undef = V(llvm::UndefValue::get(T(Float4::getType())));
+	Value *undef = V(llvm::UndefValue::get(T(Float4::type())));
 	Value *vector = Nucleus::createInsertElement(undef, val.value, 0);
 
-	return RValue<Float>(Nucleus::createExtractElement(V(jit->builder->CreateCall3(roundss, ARGS(V(undef), V(vector), V(Nucleus::createConstantInt(imm))))), Float::getType(), 0));
+	return RValue<Float>(Nucleus::createExtractElement(V(jit->builder->CreateCall3(roundss, ARGS(V(undef), V(vector), V(Nucleus::createConstantInt(imm))))), Float::type(), 0));
 }
 
 RValue<Float> floorss(RValue<Float> val)
@@ -3722,22 +3722,22 @@
 
 RValue<Short4> pcmpgtw(RValue<Short4> x, RValue<Short4> y)
 {
-	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Short4::getType()))));
+	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Short4::type()))));
 }
 
 RValue<Short4> pcmpeqw(RValue<Short4> x, RValue<Short4> y)
 {
-	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Short4::getType()))));
+	return As<Short4>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Short4::type()))));
 }
 
 RValue<Byte8> pcmpgtb(RValue<SByte8> x, RValue<SByte8> y)
 {
-	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Byte8::getType()))));
+	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_SGT, V(x.value), V(y.value), T(Byte8::type()))));
 }
 
 RValue<Byte8> pcmpeqb(RValue<Byte8> x, RValue<Byte8> y)
 {
-	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Byte8::getType()))));
+	return As<Byte8>(V(lowerPCMP(llvm::ICmpInst::ICMP_EQ, V(x.value), V(y.value), T(Byte8::type()))));
 }
 
 RValue<Short4> packssdw(RValue<Int2> x, RValue<Int2> y)
@@ -3947,22 +3947,22 @@
 
 RValue<Int4> pmovzxbd(RValue<Byte16> x)
 {
-	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::getType()), false)));
+	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::type()), false)));
 }
 
 RValue<Int4> pmovsxbd(RValue<SByte16> x)
 {
-	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::getType()), true)));
+	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::type()), true)));
 }
 
 RValue<Int4> pmovzxwd(RValue<UShort8> x)
 {
-	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::getType()), false)));
+	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::type()), false)));
 }
 
 RValue<Int4> pmovsxwd(RValue<Short8> x)
 {
-	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::getType()), true)));
+	return RValue<Int4>(V(lowerPMOV(V(x.value), T(Int4::type()), true)));
 }
 
 }  // namespace x86
diff --git a/src/Reactor/Reactor.cpp b/src/Reactor/Reactor.cpp
index dc8d960..de85b03 100644
--- a/src/Reactor/Reactor.cpp
+++ b/src/Reactor/Reactor.cpp
@@ -251,21 +251,21 @@
 
 Byte::Byte(RValue<Int> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, Byte::type());
 
 	storeValue(integer);
 }
 
 Byte::Byte(RValue<UInt> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, Byte::type());
 
 	storeValue(integer);
 }
 
 Byte::Byte(RValue<UShort> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, Byte::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, Byte::type());
 
 	storeValue(integer);
 }
@@ -508,14 +508,14 @@
 
 SByte::SByte(RValue<Int> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, SByte::type());
 
 	storeValue(integer);
 }
 
 SByte::SByte(RValue<Short> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, SByte::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, SByte::type());
 
 	storeValue(integer);
 }
@@ -753,7 +753,7 @@
 
 Short::Short(RValue<Int> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, Short::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, Short::type());
 
 	storeValue(integer);
 }
@@ -991,14 +991,14 @@
 
 UShort::UShort(RValue<UInt> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, UShort::type());
 
 	storeValue(integer);
 }
 
 UShort::UShort(RValue<Int> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, UShort::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, UShort::type());
 
 	storeValue(integer);
 }
@@ -1231,7 +1231,7 @@
 
 Byte4::Byte4(RValue<Byte8> cast)
 {
-	storeValue(Nucleus::createBitCast(cast.value, getType()));
+	storeValue(Nucleus::createBitCast(cast.value, type()));
 }
 
 Byte4::Byte4(RValue<UShort4> cast)
@@ -1293,7 +1293,7 @@
 Byte8::Byte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
 {
 	int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Byte8::Byte8(RValue<Byte8> rhs)
@@ -1507,9 +1507,9 @@
 SByte8::SByte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
 {
 	int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 };
-	Value *vector = Nucleus::createConstantVector(constantVector, getType());
+	Value *vector = Nucleus::createConstantVector(constantVector, type());
 
-	storeValue(Nucleus::createBitCast(vector, getType()));
+	storeValue(Nucleus::createBitCast(vector, type()));
 }
 
 SByte8::SByte8(RValue<SByte8> rhs)
@@ -1748,18 +1748,18 @@
 
 Short2::Short2(RValue<Short4> cast)
 {
-	storeValue(Nucleus::createBitCast(cast.value, getType()));
+	storeValue(Nucleus::createBitCast(cast.value, type()));
 }
 
 UShort2::UShort2(RValue<UShort4> cast)
 {
-	storeValue(Nucleus::createBitCast(cast.value, getType()));
+	storeValue(Nucleus::createBitCast(cast.value, type()));
 }
 
 Short4::Short4(RValue<Int> cast)
 {
 	Value *vector = loadValue();
-	Value *element = Nucleus::createTrunc(cast.value, Short::getType());
+	Value *element = Nucleus::createTrunc(cast.value, Short::type());
 	Value *insert = Nucleus::createInsertElement(vector, element, 0);
 	Value *swizzle = Swizzle(RValue<Short4>(insert), 0x0000).value;
 
@@ -1773,13 +1773,13 @@
 Short4::Short4(short xyzw)
 {
 	int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Short4::Short4(short x, short y, short z, short w)
 {
 	int64_t constantVector[4] = { x, y, z, w };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Short4::Short4(RValue<Short4> rhs)
@@ -2010,7 +2010,7 @@
 
 RValue<Short> Extract(RValue<Short4> val, int i)
 {
-	return RValue<Short>(Nucleus::createExtractElement(val.value, Short::getType(), i));
+	return RValue<Short>(Nucleus::createExtractElement(val.value, Short::type(), i));
 }
 
 UShort4::UShort4(RValue<Int4> cast)
@@ -2021,13 +2021,13 @@
 UShort4::UShort4(unsigned short xyzw)
 {
 	int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
 {
 	int64_t constantVector[4] = { x, y, z, w };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 UShort4::UShort4(RValue<UShort4> rhs)
@@ -2158,13 +2158,13 @@
 Short8::Short8(short c)
 {
 	int64_t constantVector[8] = { c, c, c, c, c, c, c, c };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
 {
 	int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Short8::Short8(RValue<Short8> rhs)
@@ -2229,13 +2229,13 @@
 UShort8::UShort8(unsigned short c)
 {
 	int64_t constantVector[8] = { c, c, c, c, c, c, c, c };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7)
 {
 	int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 UShort8::UShort8(RValue<UShort8> rhs)
@@ -2328,28 +2328,28 @@
 
 Int::Int(RValue<Byte> cast)
 {
-	Value *integer = Nucleus::createZExt(cast.value, Int::getType());
+	Value *integer = Nucleus::createZExt(cast.value, Int::type());
 
 	storeValue(integer);
 }
 
 Int::Int(RValue<SByte> cast)
 {
-	Value *integer = Nucleus::createSExt(cast.value, Int::getType());
+	Value *integer = Nucleus::createSExt(cast.value, Int::type());
 
 	storeValue(integer);
 }
 
 Int::Int(RValue<Short> cast)
 {
-	Value *integer = Nucleus::createSExt(cast.value, Int::getType());
+	Value *integer = Nucleus::createSExt(cast.value, Int::type());
 
 	storeValue(integer);
 }
 
 Int::Int(RValue<UShort> cast)
 {
-	Value *integer = Nucleus::createZExt(cast.value, Int::getType());
+	Value *integer = Nucleus::createZExt(cast.value, Int::type());
 
 	storeValue(integer);
 }
@@ -2361,14 +2361,14 @@
 
 Int::Int(RValue<Long> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, Int::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, Int::type());
 
 	storeValue(integer);
 }
 
 Int::Int(RValue<Float> cast)
 {
-	Value *integer = Nucleus::createFPToSI(cast.value, Int::getType());
+	Value *integer = Nucleus::createFPToSI(cast.value, Int::type());
 
 	storeValue(integer);
 }
@@ -2625,14 +2625,14 @@
 
 Long::Long(RValue<Int> cast)
 {
-	Value *integer = Nucleus::createSExt(cast.value, Long::getType());
+	Value *integer = Nucleus::createSExt(cast.value, Long::type());
 
 	storeValue(integer);
 }
 
 Long::Long(RValue<UInt> cast)
 {
-	Value *integer = Nucleus::createZExt(cast.value, Long::getType());
+	Value *integer = Nucleus::createZExt(cast.value, Long::type());
 
 	storeValue(integer);
 }
@@ -2747,14 +2747,14 @@
 
 UInt::UInt(RValue<UShort> cast)
 {
-	Value *integer = Nucleus::createZExt(cast.value, UInt::getType());
+	Value *integer = Nucleus::createZExt(cast.value, UInt::type());
 
 	storeValue(integer);
 }
 
 UInt::UInt(RValue<Long> cast)
 {
-	Value *integer = Nucleus::createTrunc(cast.value, UInt::getType());
+	Value *integer = Nucleus::createTrunc(cast.value, UInt::type());
 
 	storeValue(integer);
 }
@@ -3016,13 +3016,13 @@
 
 Int2::Int2(RValue<Int4> cast)
 {
-	storeValue(Nucleus::createBitCast(cast.value, getType()));
+	storeValue(Nucleus::createBitCast(cast.value, type()));
 }
 
 Int2::Int2(int x, int y)
 {
 	int64_t constantVector[2] = { x, y };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Int2::Int2(RValue<Int2> rhs)
@@ -3047,7 +3047,7 @@
 	int shuffle[4] = { 0, 4, 1, 5 };
 	Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle);
 
-	storeValue(Nucleus::createBitCast(packed, Int2::getType()));
+	storeValue(Nucleus::createBitCast(packed, Int2::type()));
 }
 
 RValue<Int2> Int2::operator=(RValue<Int2> rhs)
@@ -3195,7 +3195,7 @@
 
 RValue<Int> Extract(RValue<Int2> val, int i)
 {
-	return RValue<Int>(Nucleus::createExtractElement(val.value, Int::getType(), i));
+	return RValue<Int>(Nucleus::createExtractElement(val.value, Int::type(), i));
 }
 
 RValue<Int2> Insert(RValue<Int2> val, RValue<Int> element, int i)
@@ -3206,7 +3206,7 @@
 UInt2::UInt2(unsigned int x, unsigned int y)
 {
 	int64_t constantVector[2] = { x, y };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 UInt2::UInt2(RValue<UInt2> rhs)
@@ -3356,7 +3356,7 @@
 
 RValue<UInt> Extract(RValue<UInt2> val, int i)
 {
-	return RValue<UInt>(Nucleus::createExtractElement(val.value, UInt::getType(), i));
+	return RValue<UInt>(Nucleus::createExtractElement(val.value, UInt::type(), i));
 }
 
 RValue<UInt2> Insert(RValue<UInt2> val, RValue<UInt> element, int i)
@@ -3372,7 +3372,7 @@
 Int4::Int4(RValue<Float4> cast)
     : XYZW(this)
 {
-	Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
+	Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::type());
 
 	storeValue(xyzw);
 }
@@ -3404,7 +3404,7 @@
 void Int4::constant(int x, int y, int z, int w)
 {
 	int64_t constantVector[4] = { x, y, z, w };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Int4::Int4(RValue<Int4> rhs)
@@ -3608,7 +3608,7 @@
 
 RValue<Int> Extract(RValue<Int4> x, int i)
 {
-	return RValue<Int>(Nucleus::createExtractElement(x.value, Int::getType(), i));
+	return RValue<Int>(Nucleus::createExtractElement(x.value, Int::type(), i));
 }
 
 RValue<Int4> Insert(RValue<Int4> x, RValue<Int> element, int i)
@@ -3658,7 +3658,7 @@
 void UInt4::constant(int x, int y, int z, int w)
 {
 	int64_t constantVector[4] = { x, y, z, w };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 UInt4::UInt4(RValue<UInt4> rhs)
@@ -3862,7 +3862,7 @@
 
 RValue<UInt> Extract(RValue<UInt4> x, int i)
 {
-	return RValue<UInt>(Nucleus::createExtractElement(x.value, Int::getType(), i));
+	return RValue<UInt>(Nucleus::createExtractElement(x.value, Int::type(), i));
 }
 
 RValue<UInt4> Insert(RValue<UInt4> x, RValue<UInt> element, int i)
@@ -3910,7 +3910,7 @@
 
 Float::Float(RValue<Int> cast)
 {
-	Value *integer = Nucleus::createSIToFP(cast.value, Float::getType());
+	Value *integer = Nucleus::createSIToFP(cast.value, Float::type());
 
 	storeValue(integer);
 }
@@ -4133,14 +4133,14 @@
 
 Float2::Float2(RValue<Float4> cast)
 {
-	storeValue(Nucleus::createBitCast(cast.value, getType()));
+	storeValue(Nucleus::createBitCast(cast.value, type()));
 }
 
 Float4::Float4(RValue<Byte4> cast)
     : XYZW(this)
 {
 	Value *a = Int4(cast).loadValue();
-	Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
+	Value *xyzw = Nucleus::createSIToFP(a, Float4::type());
 
 	storeValue(xyzw);
 }
@@ -4149,7 +4149,7 @@
     : XYZW(this)
 {
 	Value *a = Int4(cast).loadValue();
-	Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
+	Value *xyzw = Nucleus::createSIToFP(a, Float4::type());
 
 	storeValue(xyzw);
 }
@@ -4158,20 +4158,20 @@
     : XYZW(this)
 {
 	Int4 c(cast);
-	storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
+	storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::type()));
 }
 
 Float4::Float4(RValue<UShort4> cast)
     : XYZW(this)
 {
 	Int4 c(cast);
-	storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
+	storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::type()));
 }
 
 Float4::Float4(RValue<Int4> cast)
     : XYZW(this)
 {
-	Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
+	Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::type());
 
 	storeValue(xyzw);
 }
@@ -4220,7 +4220,7 @@
 
 	constexpr double inf = std::numeric_limits<double>::infinity();
 	double constantVector[4] = { inf, inf, inf, inf };
-	result.storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	result.storeValue(Nucleus::createConstantVector(constantVector, type()));
 
 	return result;
 }
@@ -4231,7 +4231,7 @@
 	ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w));
 
 	double constantVector[4] = { x, y, z, w };
-	storeValue(Nucleus::createConstantVector(constantVector, getType()));
+	storeValue(Nucleus::createConstantVector(constantVector, type()));
 }
 
 Float4::Float4(RValue<Float4> rhs)
@@ -4367,9 +4367,9 @@
 RValue<Float4> Abs(RValue<Float4> x)
 {
 	// TODO: Optimize.
-	Value *vector = Nucleus::createBitCast(x.value, Int4::getType());
+	Value *vector = Nucleus::createBitCast(x.value, Int4::type());
 	int64_t constantVector[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF };
-	Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, Int4::getType()));
+	Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, Int4::type()));
 
 	return As<Float4>(result);
 }
@@ -4381,7 +4381,7 @@
 
 RValue<Float> Extract(RValue<Float4> x, int i)
 {
-	return RValue<Float>(Nucleus::createExtractElement(x.value, Float::getType(), i));
+	return RValue<Float>(Nucleus::createExtractElement(x.value, Float::type(), i));
 }
 
 RValue<Float4> Swizzle(RValue<Float4> x, uint16_t select)
@@ -4444,12 +4444,12 @@
 
 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
 {
-	return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, false));
+	return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::type(), offset.value, false));
 }
 
 RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
 {
-	return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, true));
+	return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::type(), offset.value, true));
 }
 
 RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset)
@@ -4512,12 +4512,12 @@
 
 RValue<Float4> MaskedLoad(RValue<Pointer<Float4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */)
 {
-	return RValue<Float4>(Nucleus::createMaskedLoad(base.value, Float::getType(), mask.value, alignment, zeroMaskedLanes));
+	return RValue<Float4>(Nucleus::createMaskedLoad(base.value, Float::type(), mask.value, alignment, zeroMaskedLanes));
 }
 
 RValue<Int4> MaskedLoad(RValue<Pointer<Int4>> base, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */)
 {
-	return RValue<Int4>(Nucleus::createMaskedLoad(base.value, Int::getType(), mask.value, alignment, zeroMaskedLanes));
+	return RValue<Int4>(Nucleus::createMaskedLoad(base.value, Int::type(), mask.value, alignment, zeroMaskedLanes));
 }
 
 void MaskedStore(RValue<Pointer<Float4>> base, RValue<Float4> val, RValue<Int4> mask, unsigned int alignment)
@@ -4611,7 +4611,7 @@
 // toInt returns all the integer values in vals extended to a printf-required storage value
 static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned)
 {
-	auto storageTy = Nucleus::getPrintfStorageType(Int::getType());
+	auto storageTy = Nucleus::getPrintfStorageType(Int::type());
 	std::vector<Value *> elements;
 	elements.reserve(vals.size());
 	for(auto v : vals)
@@ -4631,7 +4631,7 @@
 // toFloat returns all the float values in vals extended to extended to a printf-required storage value
 static std::vector<Value *> toFloat(const std::vector<Value *> &vals)
 {
-	auto storageTy = Nucleus::getPrintfStorageType(Float::getType());
+	auto storageTy = Nucleus::getPrintfStorageType(Float::type());
 	std::vector<Value *> elements;
 	elements.reserve(vals.size());
 	for(auto v : vals)
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index 9a99c30..f9b986d 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -90,12 +90,7 @@
 class Void
 {
 public:
-	static Type *getType();
-
-	static bool isVoid()
-	{
-		return true;
-	}
+	static Type *type();
 };
 
 template<class T>
@@ -150,11 +145,6 @@
 
 	RValue<Pointer<T>> operator&();
 
-	static bool isVoid()
-	{
-		return false;
-	}
-
 	// self() returns the this pointer to this LValue<T> object.
 	// This function exists because operator&() is overloaded.
 	inline LValue<T> *self() { return this; }
@@ -281,7 +271,7 @@
 	RValue<Bool> operator=(const Bool &rhs);
 	RValue<Bool> operator=(const Reference<Bool> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Bool> operator!(RValue<Bool> val);
@@ -311,7 +301,7 @@
 	RValue<Byte> operator=(const Byte &rhs);
 	RValue<Byte> operator=(const Reference<Byte> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Byte> operator+(RValue<Byte> lhs, RValue<Byte> rhs);
@@ -367,7 +357,7 @@
 	RValue<SByte> operator=(const SByte &rhs);
 	RValue<SByte> operator=(const Reference<SByte> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<SByte> operator+(RValue<SByte> lhs, RValue<SByte> rhs);
@@ -422,7 +412,7 @@
 	RValue<Short> operator=(const Short &rhs);
 	RValue<Short> operator=(const Reference<Short> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Short> operator+(RValue<Short> lhs, RValue<Short> rhs);
@@ -478,7 +468,7 @@
 	RValue<UShort> operator=(const UShort &rhs);
 	RValue<UShort> operator=(const Reference<UShort> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<UShort> operator+(RValue<UShort> lhs, RValue<UShort> rhs);
@@ -534,7 +524,7 @@
 	RValue<Byte4> operator=(const Byte4 &rhs);
 	//	RValue<Byte4> operator=(const Reference<Byte4> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 //	RValue<Byte4> operator+(RValue<Byte4> lhs, RValue<Byte4> rhs);
@@ -578,7 +568,7 @@
 	//	RValue<SByte4> operator=(const SByte4 &rhs);
 	//	RValue<SByte4> operator=(const Reference<SByte4> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 //	RValue<SByte4> operator+(RValue<SByte4> lhs, RValue<SByte4> rhs);
@@ -622,7 +612,7 @@
 	RValue<Byte8> operator=(const Byte8 &rhs);
 	RValue<Byte8> operator=(const Reference<Byte8> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Byte8> operator+(RValue<Byte8> lhs, RValue<Byte8> rhs);
@@ -677,7 +667,7 @@
 	RValue<SByte8> operator=(const SByte8 &rhs);
 	RValue<SByte8> operator=(const Reference<SByte8> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<SByte8> operator+(RValue<SByte8> lhs, RValue<SByte8> rhs);
@@ -728,7 +718,7 @@
 	RValue<Byte16> operator=(const Byte16 &rhs);
 	RValue<Byte16> operator=(const Reference<Byte16> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 //	RValue<Byte16> operator+(RValue<Byte16> lhs, RValue<Byte16> rhs);
@@ -773,7 +763,7 @@
 	//	RValue<SByte16> operator=(const SByte16 &rhs);
 	//	RValue<SByte16> operator=(const Reference<SByte16> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 //	RValue<SByte16> operator+(RValue<SByte16> lhs, RValue<SByte16> rhs);
@@ -809,7 +799,7 @@
 public:
 	explicit Short2(RValue<Short4> cast);
 
-	static Type *getType();
+	static Type *type();
 };
 
 class UShort2 : public LValue<UShort2>
@@ -817,7 +807,7 @@
 public:
 	explicit UShort2(RValue<UShort4> cast);
 
-	static Type *getType();
+	static Type *type();
 };
 
 class Short4 : public LValue<Short4>
@@ -845,7 +835,7 @@
 	RValue<Short4> operator=(const UShort4 &rhs);
 	RValue<Short4> operator=(const Reference<UShort4> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Short4> operator+(RValue<Short4> lhs, RValue<Short4> rhs);
@@ -922,7 +912,7 @@
 	RValue<UShort4> operator=(const Short4 &rhs);
 	RValue<UShort4> operator=(const Reference<Short4> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<UShort4> operator+(RValue<UShort4> lhs, RValue<UShort4> rhs);
@@ -975,7 +965,7 @@
 	RValue<Short8> operator=(const Short8 &rhs);
 	RValue<Short8> operator=(const Reference<Short8> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Short8> operator+(RValue<Short8> lhs, RValue<Short8> rhs);
@@ -1033,7 +1023,7 @@
 	RValue<UShort8> operator=(const UShort8 &rhs);
 	RValue<UShort8> operator=(const Reference<UShort8> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<UShort8> operator+(RValue<UShort8> lhs, RValue<UShort8> rhs);
@@ -1105,7 +1095,7 @@
 	RValue<Int> operator=(const Reference<Int> &rhs);
 	RValue<Int> operator=(const Reference<UInt> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Int> operator+(RValue<Int> lhs, RValue<Int> rhs);
@@ -1175,7 +1165,7 @@
 	//	RValue<Long> operator=(const ULong &rhs);
 	//	RValue<Long> operator=(const Reference<ULong> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Long> operator+(RValue<Long> lhs, RValue<Long> rhs);
@@ -1242,7 +1232,7 @@
 	RValue<UInt> operator=(const Reference<UInt> &rhs);
 	RValue<UInt> operator=(const Reference<Int> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<UInt> operator+(RValue<UInt> lhs, RValue<UInt> rhs);
@@ -1314,7 +1304,7 @@
 	RValue<Int2> operator=(const Int2 &rhs);
 	RValue<Int2> operator=(const Reference<Int2> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Int2> operator+(RValue<Int2> lhs, RValue<Int2> rhs);
@@ -1370,7 +1360,7 @@
 	RValue<UInt2> operator=(const UInt2 &rhs);
 	RValue<UInt2> operator=(const Reference<UInt2> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<UInt2> operator+(RValue<UInt2> lhs, RValue<UInt2> rhs);
@@ -1887,7 +1877,7 @@
 	RValue<Int4> operator=(const Int4 &rhs);
 	RValue<Int4> operator=(const Reference<Int4> &rhs);
 
-	static Type *getType();
+	static Type *type();
 
 private:
 	void constant(int x, int y, int z, int w);
@@ -1990,7 +1980,7 @@
 	RValue<UInt4> operator=(const UInt4 &rhs);
 	RValue<UInt4> operator=(const Reference<UInt4> &rhs);
 
-	static Type *getType();
+	static Type *type();
 
 private:
 	void constant(int x, int y, int z, int w);
@@ -2060,7 +2050,7 @@
 public:
 	explicit Half(RValue<Float> cast);
 
-	static Type *getType();
+	static Type *type();
 };
 
 class Float : public LValue<Float>
@@ -2090,7 +2080,7 @@
 
 	static Float infinity();
 
-	static Type *getType();
+	static Type *type();
 };
 
 RValue<Float> operator+(RValue<Float> lhs, RValue<Float> rhs);
@@ -2182,7 +2172,7 @@
 	//	template<int T>
 	//	RValue<Float2> operator=(const SwizzleMask1<T> &rhs);
 
-	static Type *getType();
+	static Type *type();
 };
 
 //	RValue<Float2> operator+(RValue<Float2> lhs, RValue<Float2> rhs);
@@ -2254,7 +2244,7 @@
 
 	static Float4 infinity();
 
-	static Type *getType();
+	static Type *type();
 
 private:
 	void constant(float x, float y, float z, float w);
@@ -2376,7 +2366,7 @@
 	Pointer(RValue<Pointer<S>> pointerS, int alignment = 1)
 	    : alignment(alignment)
 	{
-		Value *pointerT = Nucleus::createBitCast(pointerS.value, Nucleus::getPointerType(T::getType()));
+		Value *pointerT = Nucleus::createBitCast(pointerS.value, Nucleus::getPointerType(T::type()));
 		LValue<Pointer<T>>::storeValue(pointerT);
 	}
 
@@ -2385,7 +2375,7 @@
 	    : alignment(alignment)
 	{
 		Value *pointerS = pointer.loadValue();
-		Value *pointerT = Nucleus::createBitCast(pointerS, Nucleus::getPointerType(T::getType()));
+		Value *pointerT = Nucleus::createBitCast(pointerS, Nucleus::getPointerType(T::type()));
 		LValue<Pointer<T>>::storeValue(pointerT);
 	}
 
@@ -2408,7 +2398,7 @@
 	Reference<T> operator[](RValue<Int> index);
 	Reference<T> operator[](RValue<UInt> index);
 
-	static Type *getType();
+	static Type *type();
 
 private:
 	const int alignment;
@@ -2437,7 +2427,7 @@
 template<typename T>
 RValue<T> Load(RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder)
 {
-	return RValue<T>(Nucleus::createLoad(pointer.value, T::getType(), false, alignment, atomic, memoryOrder));
+	return RValue<T>(Nucleus::createLoad(pointer.value, T::type(), false, alignment, atomic, memoryOrder));
 }
 
 template<typename T>
@@ -2460,7 +2450,7 @@
 template<typename T>
 void Store(RValue<T> value, RValue<Pointer<T>> pointer, unsigned int alignment, bool atomic, std::memory_order memoryOrder)
 {
-	Nucleus::createStore(value.value, pointer.value, T::getType(), false, alignment, atomic, memoryOrder);
+	Nucleus::createStore(value.value, pointer.value, T::type(), false, alignment, atomic, memoryOrder);
 }
 
 template<typename T>
@@ -2602,7 +2592,7 @@
 
 template<class T>
 LValue<T>::LValue(int arraySize)
-    : Variable(T::getType(), arraySize)
+    : Variable(T::type(), arraySize)
 {
 #ifdef ENABLE_RR_DEBUG_INFO
 	materialize();
@@ -2680,7 +2670,7 @@
 template<class T>
 RValue<T> Reference<T>::operator=(RValue<T> rhs) const
 {
-	Nucleus::createStore(rhs.value, address, T::getType(), false, alignment);
+	Nucleus::createStore(rhs.value, address, T::type(), false, alignment);
 
 	return rhs;
 }
@@ -2688,8 +2678,8 @@
 template<class T>
 RValue<T> Reference<T>::operator=(const Reference<T> &ref) const
 {
-	Value *tmp = Nucleus::createLoad(ref.address, T::getType(), false, ref.alignment);
-	Nucleus::createStore(tmp, address, T::getType(), false, alignment);
+	Value *tmp = Nucleus::createLoad(ref.address, T::type(), false, ref.alignment);
+	Nucleus::createStore(tmp, address, T::type(), false, alignment);
 
 	return RValue<T>(tmp);
 }
@@ -2703,7 +2693,7 @@
 template<class T>
 Value *Reference<T>::loadValue() const
 {
-	return Nucleus::createLoad(address, T::getType(), false, alignment);
+	return Nucleus::createLoad(address, T::type(), false, alignment);
 }
 
 template<class T>
@@ -2724,7 +2714,7 @@
 template<class T>
 RValue<T>::RValue(Value *rvalue)
 {
-	assert(Nucleus::createBitCast(rvalue, T::getType()) == rvalue);  // Run-time type should match T, so bitcast is no-op.
+	assert(Nucleus::createBitCast(rvalue, T::type()) == rvalue);  // Run-time type should match T, so bitcast is no-op.
 
 	value = rvalue;
 	RR_DEBUG_INFO_EMIT_VAR(value);
@@ -2974,7 +2964,7 @@
 Pointer<T>::Pointer(std::nullptr_t)
     : alignment(1)
 {
-	Value *value = Nucleus::createNullPointer(T::getType());
+	Value *value = Nucleus::createNullPointer(T::type());
 	LValue<Pointer<T>>::storeValue(value);
 }
 
@@ -3007,7 +2997,7 @@
 template<class T>
 RValue<Pointer<T>> Pointer<T>::operator=(std::nullptr_t)
 {
-	Value *value = Nucleus::createNullPointer(T::getType());
+	Value *value = Nucleus::createNullPointer(T::type());
 	LValue<Pointer<T>>::storeValue(value);
 
 	return RValue<Pointer<T>>(this);
@@ -3023,7 +3013,7 @@
 Reference<T> Pointer<T>::operator[](int index)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), Nucleus::createConstantInt(index), false);
+	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::type(), Nucleus::createConstantInt(index), false);
 
 	return Reference<T>(element, alignment);
 }
@@ -3032,7 +3022,7 @@
 Reference<T> Pointer<T>::operator[](unsigned int index)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), Nucleus::createConstantInt(index), true);
+	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::type(), Nucleus::createConstantInt(index), true);
 
 	return Reference<T>(element, alignment);
 }
@@ -3041,7 +3031,7 @@
 Reference<T> Pointer<T>::operator[](RValue<Int> index)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), index.value, false);
+	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::type(), index.value, false);
 
 	return Reference<T>(element, alignment);
 }
@@ -3050,15 +3040,15 @@
 Reference<T> Pointer<T>::operator[](RValue<UInt> index)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::getType(), index.value, true);
+	Value *element = Nucleus::createGEP(LValue<Pointer<T>>::loadValue(), T::type(), index.value, true);
 
 	return Reference<T>(element, alignment);
 }
 
 template<class T>
-Type *Pointer<T>::getType()
+Type *Pointer<T>::type()
 {
-	return Nucleus::getPointerType(T::getType());
+	return Nucleus::getPointerType(T::type());
 }
 
 template<class T, int S>
@@ -3070,7 +3060,7 @@
 template<class T, int S>
 Reference<T> Array<T, S>::operator[](int index)
 {
-	assert(index < this->arraySize);
+	assert(index < Variable::arraySize);
 	Value *element = LValue<T>::getElementPointer(Nucleus::createConstantInt(index), false);
 
 	return Reference<T>(element);
@@ -3079,7 +3069,7 @@
 template<class T, int S>
 Reference<T> Array<T, S>::operator[](unsigned int index)
 {
-	assert(index < static_cast<unsigned int>(this->arraySize));
+	assert(index < static_cast<unsigned int>(Variable::arraySize));
 	Value *element = LValue<T>::getElementPointer(Nucleus::createConstantInt(index), true);
 
 	return Reference<T>(element);
@@ -3165,16 +3155,16 @@
 {
 	core = new Nucleus();
 
-	Type *types[] = { Arguments::getType()... };
+	Type *types[] = { Arguments::type()... };
 	for(Type *type : types)
 	{
-		if(type != Void::getType())
+		if(type != Void::type())
 		{
 			arguments.push_back(type);
 		}
 	}
 
-	Nucleus::createFunction(Return::getType(), arguments);
+	Nucleus::createFunction(Return::type(), arguments);
 }
 
 template<typename Return, typename... Arguments>
@@ -3213,7 +3203,7 @@
 RValue<T> ReinterpretCast(RValue<S> val)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<T>(Nucleus::createBitCast(val.value, T::getType()));
+	return RValue<T>(Nucleus::createBitCast(val.value, T::type()));
 }
 
 template<class T, class S>
@@ -3222,7 +3212,7 @@
 	RR_DEBUG_INFO_UPDATE_LOC();
 	Value *val = var.loadValue();
 
-	return RValue<T>(Nucleus::createBitCast(val, T::getType()));
+	return RValue<T>(Nucleus::createBitCast(val, T::type()));
 }
 
 template<class T, class S>
@@ -3235,7 +3225,7 @@
 RValue<T> As(Value *val)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<T>(Nucleus::createBitCast(val, T::getType()));
+	return RValue<T>(Nucleus::createBitCast(val, T::type()));
 }
 
 template<class T, class S>
@@ -3275,18 +3265,18 @@
 	{
 		return RValue<RReturn>(rr::Call(
 		    ConstantPointer(reinterpret_cast<void *>(fptr)),
-		    RReturn::getType(),
+		    RReturn::type(),
 		    { ValueOf(args)... },
-		    { CToReactorT<Arguments>::getType()... }));
+		    { CToReactorT<Arguments>::type()... }));
 	}
 
 	static inline RReturn Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args)
 	{
 		return RValue<RReturn>(rr::Call(
 		    fptr,
-		    RReturn::getType(),
+		    RReturn::type(),
 		    { ValueOf(args)... },
-		    { CToReactorT<Arguments>::getType()... }));
+		    { CToReactorT<Arguments>::type()... }));
 	}
 };
 
@@ -3297,17 +3287,17 @@
 	static inline void Call(void(fptr)(Arguments...), CToReactorT<Arguments>... args)
 	{
 		rr::Call(ConstantPointer(reinterpret_cast<void *>(fptr)),
-		         Void::getType(),
+		         Void::type(),
 		         { ValueOf(args)... },
-		         { CToReactorT<Arguments>::getType()... });
+		         { CToReactorT<Arguments>::type()... });
 	}
 
 	static inline void Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args)
 	{
 		rr::Call(fptr,
-		         Void::getType(),
+		         Void::type(),
 		         { ValueOf(args)... },
-		         { CToReactorT<Arguments>::getType()... });
+		         { CToReactorT<Arguments>::type()... });
 	}
 };
 
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 1a4a666..16ff015 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -165,7 +165,7 @@
 {
 	static_assert(sizeof...(CArgs) == sizeof...(RArgs), "Expected number of args don't match");
 
-	Ice::Type retTy = T(rr::CToReactorT<Return>::getType());
+	Ice::Type retTy = T(rr::CToReactorT<Return>::type());
 	std::vector<Ice::Operand *> iceArgs{ std::forward<RArgs>(args)... };
 	return Call(function, basicBlock, retTy, reinterpret_cast<void const *>(fptr), iceArgs, false);
 }
@@ -2165,42 +2165,42 @@
 	return V(IceConstantData(v, strlen(v) + 1));
 }
 
-Type *Void::getType()
+Type *Void::type()
 {
 	return T(Ice::IceType_void);
 }
 
-Type *Bool::getType()
+Type *Bool::type()
 {
 	return T(Ice::IceType_i1);
 }
 
-Type *Byte::getType()
+Type *Byte::type()
 {
 	return T(Ice::IceType_i8);
 }
 
-Type *SByte::getType()
+Type *SByte::type()
 {
 	return T(Ice::IceType_i8);
 }
 
-Type *Short::getType()
+Type *Short::type()
 {
 	return T(Ice::IceType_i16);
 }
 
-Type *UShort::getType()
+Type *UShort::type()
 {
 	return T(Ice::IceType_i16);
 }
 
-Type *Byte4::getType()
+Type *Byte4::type()
 {
 	return T(Type_v4i8);
 }
 
-Type *SByte4::getType()
+Type *SByte4::type()
 {
 	return T(Type_v4i8);
 }
@@ -2213,7 +2213,7 @@
 
 RValue<Byte> Extract(RValue<Byte8> val, int i)
 {
-	return RValue<Byte>(Nucleus::createExtractElement(val.value, Byte::getType(), i));
+	return RValue<Byte>(Nucleus::createExtractElement(val.value, Byte::type(), i));
 }
 
 RValue<Byte8> Insert(RValue<Byte8> val, RValue<Byte> element, int i)
@@ -2287,7 +2287,7 @@
 RValue<SByte> Extract(RValue<SByte8> val, int i)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<SByte>(Nucleus::createExtractElement(val.value, SByte::getType(), i));
+	return RValue<SByte>(Nucleus::createExtractElement(val.value, SByte::type(), i));
 }
 
 RValue<SByte8> Insert(RValue<SByte8> val, RValue<SByte> element, int i)
@@ -2359,7 +2359,7 @@
 	return RValue<Byte8>(Nucleus::createICmpEQ(x.value, y.value));
 }
 
-Type *Byte8::getType()
+Type *Byte8::type()
 {
 	return T(Type_v8i8);
 }
@@ -2475,27 +2475,27 @@
 	return RValue<Byte8>(Nucleus::createICmpEQ(x.value, y.value));
 }
 
-Type *SByte8::getType()
+Type *SByte8::type()
 {
 	return T(Type_v8i8);
 }
 
-Type *Byte16::getType()
+Type *Byte16::type()
 {
 	return T(Ice::IceType_v16i8);
 }
 
-Type *SByte16::getType()
+Type *SByte16::type()
 {
 	return T(Ice::IceType_v16i8);
 }
 
-Type *Short2::getType()
+Type *Short2::type()
 {
 	return T(Type_v2i16);
 }
 
-Type *UShort2::getType()
+Type *UShort2::type()
 {
 	return T(Type_v2i16);
 }
@@ -2503,11 +2503,11 @@
 Short4::Short4(RValue<Int4> cast)
 {
 	int select[8] = { 0, 2, 4, 6, 0, 2, 4, 6 };
-	Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType());
+	Value *short8 = Nucleus::createBitCast(cast.value, Short8::type());
 	Value *packed = Nucleus::createShuffleVector(short8, short8, select);
 
 	Value *int2 = RValue<Int2>(Int2(As<Int4>(packed))).value;
-	Value *short4 = Nucleus::createBitCast(int2, Short4::getType());
+	Value *short4 = Nucleus::createBitCast(int2, Short4::type());
 
 	storeValue(short4);
 }
@@ -2776,7 +2776,7 @@
 	return RValue<Short4>(Nucleus::createICmpEQ(x.value, y.value));
 }
 
-Type *Short4::getType()
+Type *Short4::type()
 {
 	return T(Type_v4i16);
 }
@@ -2811,7 +2811,7 @@
 
 RValue<UShort> Extract(RValue<UShort4> val, int i)
 {
-	return RValue<UShort>(Nucleus::createExtractElement(val.value, UShort::getType(), i));
+	return RValue<UShort>(Nucleus::createExtractElement(val.value, UShort::type(), i));
 }
 
 RValue<UShort4> Insert(RValue<UShort4> val, RValue<UShort> element, int i)
@@ -3027,7 +3027,7 @@
 	return UShort4(0);
 }
 
-Type *UShort4::getType()
+Type *UShort4::type()
 {
 	return T(Type_v4i16);
 }
@@ -3035,7 +3035,7 @@
 RValue<Short> Extract(RValue<Short8> val, int i)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<Short>(Nucleus::createExtractElement(val.value, Short::getType(), i));
+	return RValue<Short>(Nucleus::createExtractElement(val.value, Short::type(), i));
 }
 
 RValue<Short8> Insert(RValue<Short8> val, RValue<Short> element, int i)
@@ -3104,7 +3104,7 @@
 	return Short8(0);
 }
 
-Type *Short8::getType()
+Type *Short8::type()
 {
 	return T(Ice::IceType_v8i16);
 }
@@ -3112,7 +3112,7 @@
 RValue<UShort> Extract(RValue<UShort8> val, int i)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	return RValue<UShort>(Nucleus::createExtractElement(val.value, UShort::getType(), i));
+	return RValue<UShort>(Nucleus::createExtractElement(val.value, UShort::type(), i));
 }
 
 RValue<UShort8> Insert(RValue<UShort8> val, RValue<UShort> element, int i)
@@ -3174,7 +3174,7 @@
 	return UShort8(0);
 }
 
-Type *UShort8::getType()
+Type *UShort8::type()
 {
 	return T(Ice::IceType_v8i16);
 }
@@ -3230,12 +3230,12 @@
 	}
 }
 
-Type *Int::getType()
+Type *Int::type()
 {
 	return T(Ice::IceType_i32);
 }
 
-Type *Long::getType()
+Type *Long::type()
 {
 	return T(Ice::IceType_i64);
 }
@@ -3293,21 +3293,21 @@
 //		ASSERT(false && "UNIMPLEMENTED"); return RValue<UInt>(V(nullptr));
 //	}
 
-Type *UInt::getType()
+Type *UInt::type()
 {
 	return T(Ice::IceType_i32);
 }
 
 //	Int2::Int2(RValue<Int> cast)
 //	{
-//		Value *extend = Nucleus::createZExt(cast.value, Long::getType());
-//		Value *vector = Nucleus::createBitCast(extend, Int2::getType());
+//		Value *extend = Nucleus::createZExt(cast.value, Long::type());
+//		Value *vector = Nucleus::createBitCast(extend, Int2::type());
 //
 //		Constant *shuffle[2];
 //		shuffle[0] = Nucleus::createConstantInt(0);
 //		shuffle[1] = Nucleus::createConstantInt(0);
 //
-//		Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::getType()), Nucleus::createConstantVector(shuffle, 2));
+//		Value *replicate = Nucleus::createShuffleVector(vector, UndefValue::get(Int2::type()), Nucleus::createConstantVector(shuffle, 2));
 //
 //		storeValue(replicate);
 //	}
@@ -3346,7 +3346,7 @@
 	}
 }
 
-Type *Int2::getType()
+Type *Int2::type()
 {
 	return T(Type_v2i32);
 }
@@ -3385,7 +3385,7 @@
 	}
 }
 
-Type *UInt2::getType()
+Type *UInt2::type()
 {
 	return T(Type_v2i32);
 }
@@ -3394,19 +3394,19 @@
     : XYZW(this)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *x = Nucleus::createBitCast(cast.value, Int::getType());
+	Value *x = Nucleus::createBitCast(cast.value, Int::type());
 	Value *a = Nucleus::createInsertElement(loadValue(), x, 0);
 
 	Value *e;
 	int swizzle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 };
-	Value *b = Nucleus::createBitCast(a, Byte16::getType());
-	Value *c = Nucleus::createShuffleVector(b, Nucleus::createNullValue(Byte16::getType()), swizzle);
+	Value *b = Nucleus::createBitCast(a, Byte16::type());
+	Value *c = Nucleus::createShuffleVector(b, Nucleus::createNullValue(Byte16::type()), swizzle);
 
 	int swizzle2[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
-	Value *d = Nucleus::createBitCast(c, Short8::getType());
-	e = Nucleus::createShuffleVector(d, Nucleus::createNullValue(Short8::getType()), swizzle2);
+	Value *d = Nucleus::createBitCast(c, Short8::type());
+	e = Nucleus::createShuffleVector(d, Nucleus::createNullValue(Short8::type()), swizzle2);
 
-	Value *f = Nucleus::createBitCast(e, Int4::getType());
+	Value *f = Nucleus::createBitCast(e, Int4::type());
 	storeValue(f);
 }
 
@@ -3414,15 +3414,15 @@
     : XYZW(this)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *x = Nucleus::createBitCast(cast.value, Int::getType());
+	Value *x = Nucleus::createBitCast(cast.value, Int::type());
 	Value *a = Nucleus::createInsertElement(loadValue(), x, 0);
 
 	int swizzle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
-	Value *b = Nucleus::createBitCast(a, Byte16::getType());
+	Value *b = Nucleus::createBitCast(a, Byte16::type());
 	Value *c = Nucleus::createShuffleVector(b, b, swizzle);
 
 	int swizzle2[8] = { 0, 0, 1, 1, 2, 2, 3, 3 };
-	Value *d = Nucleus::createBitCast(c, Short8::getType());
+	Value *d = Nucleus::createBitCast(c, Short8::type());
 	Value *e = Nucleus::createShuffleVector(d, d, swizzle2);
 
 	*this = As<Int4>(e) >> 24;
@@ -3444,7 +3444,7 @@
 	RR_DEBUG_INFO_UPDATE_LOC();
 	int swizzle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
 	Value *c = Nucleus::createShuffleVector(cast.value, Short8(0, 0, 0, 0, 0, 0, 0, 0).loadValue(), swizzle);
-	Value *d = Nucleus::createBitCast(c, Int4::getType());
+	Value *d = Nucleus::createBitCast(c, Int4::type());
 	storeValue(d);
 }
 
@@ -3452,7 +3452,7 @@
     : XYZW(this)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *vector = Nucleus::createBitCast(rhs.value, Int4::getType());
+	Value *vector = Nucleus::createBitCast(rhs.value, Int4::type());
 
 	int swizzle[4] = { 0, 0, 0, 0 };
 	Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
@@ -3662,7 +3662,7 @@
 	}
 }
 
-Type *Int4::getType()
+Type *Int4::type()
 {
 	return T(Ice::IceType_v4i32);
 }
@@ -3689,7 +3689,7 @@
     : XYZW(this)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *vector = Nucleus::createBitCast(rhs.value, UInt4::getType());
+	Value *vector = Nucleus::createBitCast(rhs.value, UInt4::type());
 
 	int swizzle[4] = { 0, 0, 0, 0 };
 	Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
@@ -3799,12 +3799,12 @@
 	return RValue<UInt4>(V(result));
 }
 
-Type *UInt4::getType()
+Type *UInt4::type()
 {
 	return T(Ice::IceType_v4i32);
 }
 
-Type *Half::getType()
+Type *Half::type()
 {
 	return T(Ice::IceType_i16);
 }
@@ -3864,12 +3864,12 @@
 	return Float4(Ceil(Float4(x))).x;
 }
 
-Type *Float::getType()
+Type *Float::type()
 {
 	return T(Ice::IceType_f32);
 }
 
-Type *Float2::getType()
+Type *Float2::type()
 {
 	return T(Type_v2f32);
 }
@@ -3878,7 +3878,7 @@
     : XYZW(this)
 {
 	RR_DEBUG_INFO_UPDATE_LOC();
-	Value *vector = Nucleus::createBitCast(rhs.value, Float4::getType());
+	Value *vector = Nucleus::createBitCast(rhs.value, Float4::type());
 
 	int swizzle[4] = { 0, 0, 0, 0 };
 	Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
@@ -4155,7 +4155,7 @@
 	}
 }
 
-Type *Float4::getType()
+Type *Float4::type()
 {
 	return T(Ice::IceType_v4f32);
 }
