Use regex to avoid issues with reserved class names

Closes #261.