@mcheung610, do you have any plans on breaking up this file into platform specific implementations? Things are getting ugly here. I'd rather refactor it that way than to put more `#ifdefs` here.