Refactored initialize method.