code cleanup and add connection and device api ref