Reverse the order of category implementation and added C-functions