Adding first hopefully working code of SW extraction.