Some work on the API;Slight optimization of categories