Merged some old code, started on data retrieval