Added data extraction functionality. Not debugged.