After a looooooong struggle the quote escaping problem was solved. There doesn't seem to be clean solutions available, so I did it the dirty way. It works anyway.