Function injection and some fixes