Revert "Remove blank node prefix and replacement."

This reverts commit 752e19828fe60d28b038a5564163d0bdbceb0b25.
Revert "Disable broken and useless query 'optimization'."

This reverts commit 858784e9871302a61feeaaeda9a8ecca603867d4.