Extraction of useful substances from waste material