XML/JSON Support, Major Refactoring

Now supports xml and json, major refactoring on resource functions,
improved oauth error handling