Split up pkg & cleanup code