Implement pickle code