Added logging, improved data management