Major improvements in robustness and features.

Added support for writing data in a postgresql.
Improved handling of missing data.