Add missing intrinsics and fix bugs