Cleaned up some type encoder code