Move some utility methods from API package to avoid class loading issue