Fixing some issues with dot products causing dimension mismatch errors.