Refactored spark related code into a separate package