Fix bugs from new function style