Fixed weird type-related bugs