Several fixes for custom post type hooks.