Ported the functions file. Made few changes to get timings easier