A few small updates

1. Add licensing header
2. Change the order of object vs string search. Android seems to like it better this way for some unknown reason.
3. Add null check when calling toObject or toJSON methods

DM me if more changes need to be made.