Adds init function and self vars