Updated to API version 13 and cleaned up