Some cleanup, renaming + better escape rules