Refactored, fixed compile issues related to integration.