new apis and code cleanup