Fix crash when calling has/get/set_ability() with wrong name. Fix #408.

Also refactor the C++ part to use an enum instead of strings for
abilities.