Major refactoring

Primitive BOOL and number types are now NSNumber objects. Instead of
testing NSNotFound, check if nil.