Fix matrix ptr functions