more flexible prefix
make sure to only replace an actual prefix
cleans up variable to hash conversion