Add smarter name parsing code

Fixes #14