Further progress. Now adding database support. Work in progress.