Fix bug where return statements are not properly translated to IR