Rewrote the init() function.